Skip to content

Commit

Permalink
fix($core): never throw error if layout component does not exist (#1247)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy authored and ulivz committed Jan 29, 2019
1 parent 1284944 commit 49c5983
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/@vuepress/core/lib/prepare/loadTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,15 @@ module.exports = async function loadTheme (ctx) {

const layoutComponentMap = layoutDirs
.map(
layourDir => readdirSync(layourDir)
layoutDir => readdirSync(layoutDir)
.filter(filename => filename.endsWith('.vue'))
.map(filename => {
const componentName = getComponentName(filename)
return {
filename, componentName,
filename,
componentName,
isInternal: isInternal(componentName),
path: path.resolve(layourDir, filename)
path: path.resolve(layoutDir, filename)
}
})
)
Expand All @@ -148,14 +149,15 @@ module.exports = async function loadTheme (ctx) {

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

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

// use default 404 component.
if (!NotFound || !fs.existsSync(NotFound.path)) {
layoutComponentMap.NotFound = {
filename: 'Layout.vue',
filename: 'NotFound.vue',
componentName: 'NotFound',
path: path.resolve(__dirname, '../app/components/NotFound.vue'),
isInternal: true
Expand Down

0 comments on commit 49c5983

Please sign in to comment.