This repository was archived by the owner on Jan 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
core/docz-core/src/bundler/machine Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const ensureFile = (filename: string, toDelete?: string) => {
19
19
}
20
20
21
21
export const ensureFiles = ( { args } : ServerMachineCtx ) => {
22
+ // themesDir defaults to "src" to behave like a normal gatsby site
22
23
const appPath = path . join ( paths . root , args . themesDir )
23
24
const themeNames = glob . sync ( 'gatsby-theme-**' , {
24
25
cwd : appPath ,
@@ -30,6 +31,13 @@ export const ensureFiles = ({ args }: ServerMachineCtx) => {
30
31
path . join ( paths . docz , 'src' , themeName )
31
32
)
32
33
} )
34
+ const userPagesPath = path . join ( appPath , 'pages' )
35
+ const doczPagesPath = path . join ( paths . docz , 'src' , 'pages' )
36
+ // Copy 404 and other possible Gatsby pages
37
+ if ( fs . existsSync ( userPagesPath ) ) {
38
+ fs . copySync ( userPagesPath , doczPagesPath )
39
+ }
40
+
33
41
copyDoczRc ( args . config )
34
42
ensureFile ( 'gatsby-browser.js' )
35
43
ensureFile ( 'gatsby-ssr.js' )
Original file line number Diff line number Diff line change @@ -80,8 +80,10 @@ const copyEslintIgnore = async () => {
80
80
}
81
81
}
82
82
83
- export const writeNotFound = async ( ) => {
83
+ export const writeDefaultNotFound = async ( ) => {
84
84
const outputPath = path . join ( paths . docz , 'src/pages/404.js' )
85
+ // If it exists then it would have been created in ensureFiles while copying the theme
86
+ if ( fs . existsSync ( outputPath ) ) return
85
87
await outputFileFromTemplate ( '404.tpl.js' , outputPath , { } )
86
88
}
87
89
@@ -132,7 +134,7 @@ export const createResources = async (ctx: ServerMachineCtx) => {
132
134
await copyAndModifyPkgJson ( ctx )
133
135
await writeEslintRc ( )
134
136
await copyEslintIgnore ( )
135
- await writeNotFound ( )
137
+ await writeDefaultNotFound ( )
136
138
await writeGatsbyConfig ( ctx )
137
139
await writeGatsbyConfigNode ( )
138
140
await writeGatsbyConfigCustom ( )
You can’t perform that action at this time.
0 commit comments