Skip to content

Commit 35922bc

Browse files
committed
fall back to English if translated path not found
1 parent a08cd65 commit 35922bc

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

lib/create-tree.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = async function createTree (originalPath, langObj) {
2020
const localizedBasePath = path.posix.join(__dirname, '..', langObj.dir, 'content')
2121

2222
// Initialize the Page! This is where the file reads happen.
23-
const page = await Page.init({
23+
let page = await Page.init({
2424
basePath: localizedBasePath,
2525
relativePath,
2626
languageCode: langObj.code
@@ -29,10 +29,17 @@ module.exports = async function createTree (originalPath, langObj) {
2929
if (!page) {
3030
// Do not throw an error if Early Access is not available.
3131
if (relativePath.startsWith('early-access')) return
32-
// Do not throw an error if this is a translated path, as translations are not always up-to-date.
33-
if (langObj.code !== 'en') return
34-
35-
throw Error(`Cannot initialize page for ${filepath}`)
32+
// If a translated path doesn't exist, fall back to the English so there is parity between
33+
// the English tree and the translated trees.
34+
if (langObj.code !== 'en') {
35+
page = await Page.init({
36+
basePath: basePath,
37+
relativePath,
38+
languageCode: langObj.code
39+
})
40+
}
41+
42+
if (!page) throw Error(`Cannot initialize page for ${filepath}`)
3643
}
3744

3845
// Create the root tree object on the first run, and create children recursively.

0 commit comments

Comments
 (0)