Skip to content

Commit 49c5983

Browse files
meteorlxyulivz
authored andcommitted
fix($core): never throw error if layout component does not exist (#1247)
1 parent 1284944 commit 49c5983

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,15 @@ module.exports = async function loadTheme (ctx) {
124124

125125
const layoutComponentMap = layoutDirs
126126
.map(
127-
layourDir => readdirSync(layourDir)
127+
layoutDir => readdirSync(layoutDir)
128128
.filter(filename => filename.endsWith('.vue'))
129129
.map(filename => {
130130
const componentName = getComponentName(filename)
131131
return {
132-
filename, componentName,
132+
filename,
133+
componentName,
133134
isInternal: isInternal(componentName),
134-
path: path.resolve(layourDir, filename)
135+
path: path.resolve(layoutDir, filename)
135136
}
136137
})
137138
)
@@ -148,14 +149,15 @@ module.exports = async function loadTheme (ctx) {
148149

149150
const { Layout = {}, NotFound = {}} = layoutComponentMap
150151

151-
if (!Layout && !fs.existsSync(Layout.path)) {
152+
// layout component does not exist.
153+
if (!Layout || !fs.existsSync(Layout.path)) {
152154
throw new Error(`[vuepress] Cannot resolve Layout.vue file in \n ${Layout.path}`)
153155
}
154156

155157
// use default 404 component.
156158
if (!NotFound || !fs.existsSync(NotFound.path)) {
157159
layoutComponentMap.NotFound = {
158-
filename: 'Layout.vue',
160+
filename: 'NotFound.vue',
159161
componentName: 'NotFound',
160162
path: path.resolve(__dirname, '../app/components/NotFound.vue'),
161163
isInternal: true

0 commit comments

Comments
 (0)