Skip to content

Commit d6ec9cf

Browse files
committed
refactor: When Vue SFCs are source files, make them as layout components directly.
1 parent dfb0bba commit d6ec9cf

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/@vuepress/core/lib/internal-plugins/routes.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ function importCode () {
1616
return `
1717
import { injectComponentOption } from '@app/util'
1818
import rootMixins from '@internal/root-mixins'
19-
import components from '@internal/layout-components'
19+
import layoutComponents from '@internal/layout-components'
20+
import pageComponents from '@internal/page-components'
2021
import LayoutDistributor from '@app/components/LayoutDistributor.vue'
2122
2223
injectComponentOption(LayoutDistributor, 'mixins', rootMixins)
23-
injectComponentOption(LayoutDistributor, 'components', components)
24+
injectComponentOption(LayoutDistributor, 'components', Object.assign({}, layoutComponents, pageComponents))
2425
`
2526
}
2627

packages/@vuepress/core/lib/prepare/Page.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ module.exports = class Page {
123123
}
124124
} else if (this._filePath.endsWith('.vue')) {
125125
const { data = {}} = parseVueFrontmatter(this._content)
126-
this.frontmatter = data
126+
// When Vue SFCs are source files, make them as layout components directly.
127+
this.frontmatter = Object.assign({
128+
layout: this.key
129+
}, data)
127130
}
128131
}
129132

0 commit comments

Comments
 (0)