Skip to content

Commit a08cd65

Browse files
committed
set basePath as constant
1 parent a2e2017 commit a08cd65

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

lib/create-tree.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ const fs = require('fs').promises
22
const path = require('path')
33
const Page = require('./page')
44
const { sortBy } = require('lodash')
5-
6-
let basePath
5+
const basePath = path.posix.join(__dirname, '..', 'content')
76

87
module.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

lib/page-data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const languages = require('./languages')
33
const versions = Object.keys(require('./all-versions'))
44
const createTree = require('./create-tree')
55
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
6-
const englishPath = path.join(__dirname, '..', 'content')
6+
const englishPath = path.posix.join(__dirname, '..', 'content')
77

88
/**
99
* We only need to initialize pages _once per language_ since pages don't change per version. So we do that

0 commit comments

Comments
 (0)