Skip to content

Commit ade62c9

Browse files
committed
fix($core): null check for Layout components
1 parent f74ccdd commit ade62c9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,18 @@ module.exports = async function loadTheme (theme, sourceDir, vuepressDir) {
7474
return map
7575
}, {})
7676

77-
if (!fs.existsSync(layoutComponentMap.Layout.path)) {
77+
if (!layoutComponentMap.Layout && !fs.existsSync(layoutComponentMap.Layout.path)) {
7878
throw new Error(`[vuepress] Cannot resolve Layout.vue file in \n ${layoutComponentMap.Layout.path}`)
7979
}
8080

81-
if (!fs.existsSync(layoutComponentMap.NotFound.path)) {
82-
layoutComponentMap['404'].path = path.resolve(__dirname, '../app/components/NotFound.vue')
81+
// use default 404 component.
82+
if (!layoutComponentMap.NotFound || !fs.existsSync(layoutComponentMap.NotFound.path)) {
83+
layoutComponentMap['404'] = {
84+
filename: 'Layout.vue',
85+
componentName: 'NotFound',
86+
path: path.resolve(__dirname, '../app/components/NotFound.vue'),
87+
isInternal: true
88+
}
8389
}
8490

8591
return {

0 commit comments

Comments
 (0)