@@ -2,8 +2,9 @@ const { logger, fs, path: { resolve }} = require('@vuepress/shared-utils')
2
2
const readdirSync = dir => fs . existsSync ( dir ) && fs . readdirSync ( dir ) || [ ]
3
3
4
4
module . exports = class ThemeAPI {
5
- constructor ( theme , parentTheme ) {
5
+ constructor ( theme , parentTheme , context ) {
6
6
this . theme = theme
7
+ this . context = context
7
8
this . parentTheme = parentTheme || { }
8
9
this . existsParentTheme = ! ! this . parentTheme . path
9
10
this . vuepressPlugin = {
@@ -69,22 +70,22 @@ module.exports = class ThemeAPI {
69
70
// built-in named layout or not.
70
71
const layoutComponentMap = resolveSFCs ( layoutDirs )
71
72
72
- const { Layout = { } , NotFound = { } } = layoutComponentMap
73
+ const { Layout, NotFound } = layoutComponentMap
73
74
// layout component does not exist.
74
- if ( ! Layout || ! fs . existsSync ( Layout . path ) ) {
75
+ if ( ! Layout ) {
75
76
const fallbackLayoutPath = resolve ( __dirname , 'Layout.fallback.vue' )
76
77
layoutComponentMap . Layout = {
77
78
filename : 'Layout.vue' ,
78
79
componentName : 'Layout' ,
79
80
path : fallbackLayoutPath ,
80
81
isInternal : true
81
82
}
82
- logger . warn (
83
- `[vuepress] Cannot resolve Layout.vue file in \n ${ Layout . path } ,`
84
- + ` fallback to default layout: ${ fallbackLayoutPath } `
85
- )
83
+ if ( this . context . globalLayout !== this . context . getLibFilePath ( 'client/components/GlobalLayout.vue' ) ) {
84
+ // doesn't expect a Layout.vue when a custom GlobalLayout is registered
85
+ logger . warn ( `[vuepress] Cannot find Layout.vue, fallback to default layout.` )
86
+ }
86
87
}
87
- if ( ! NotFound || ! fs . existsSync ( NotFound . path ) ) {
88
+ if ( ! NotFound ) {
88
89
layoutComponentMap . NotFound = {
89
90
filename : 'NotFound.vue' ,
90
91
componentName : 'NotFound' ,
0 commit comments