@@ -2,13 +2,9 @@ const fs = require('fs').promises
22const path = require ( 'path' )
33const Page = require ( './page' )
44const { sortBy } = require ( 'lodash' )
5-
6- let basePath
5+ const basePath = path . posix . join ( __dirname , '..' , 'content' )
76
87module . exports = async function createTree ( originalPath , langObj ) {
9- // Do not reset this value on recursive runs.
10- if ( ! basePath ) basePath = originalPath
11-
128 // On recursive runs, this is processing page.children items in `/<link>` format.
139 // If the path exists as is, assume this is a directory with a child index.md.
1410 // Otherwise, assume it's a child .md file and add `.md` to the path.
@@ -21,7 +17,7 @@ module.exports = async function createTree (originalPath, langObj) {
2117 }
2218
2319 const relativePath = filepath . replace ( `${ basePath } /` , '' )
24- const localizedBasePath = path . join ( __dirname , '..' , langObj . dir , 'content' )
20+ const localizedBasePath = path . posix . join ( __dirname , '..' , langObj . dir , 'content' )
2521
2622 // Initialize the Page! This is where the file reads happen.
2723 const page = await Page . init ( {
@@ -48,7 +44,7 @@ module.exports = async function createTree (originalPath, langObj) {
4844 if ( item . page . children ) {
4945 item . childPages = sortBy (
5046 ( await Promise . all ( item . page . children
51- . map ( async ( child ) => await createTree ( path . join ( originalPath , child ) , langObj ) ) ) )
47+ . map ( async ( child ) => await createTree ( path . posix . join ( originalPath , child ) , langObj ) ) ) )
5248 . filter ( Boolean ) ,
5349 // Sort by the ordered array of `children` in the frontmatter.
5450 item . page . children
0 commit comments