From 0333ea39fbf63d0de5ad442a086b480a17ec9ccb Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Thu, 1 Jul 2021 12:13:06 -0400 Subject: [PATCH] initialize Pages for existing translated paths, not just English paths with localized versions of those paths --- lib/create-tree.js | 6 +++--- lib/page-data.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/create-tree.js b/lib/create-tree.js index b1a499fb8a..604a07ab9e 100644 --- a/lib/create-tree.js +++ b/lib/create-tree.js @@ -1,9 +1,10 @@ const fs = require('fs').promises const path = require('path') const Page = require('./page') -const basePath = path.posix.join(__dirname, '..', 'content') module.exports = async function createTree (originalPath, langObj) { + const basePath = path.posix.join(__dirname, '..', langObj.dir, 'content') + // On recursive runs, this is processing page.children items in `/` format. // If the path exists as is, assume this is a directory with a child index.md. // Otherwise, assume it's a child .md file and add `.md` to the path. @@ -16,11 +17,10 @@ module.exports = async function createTree (originalPath, langObj) { } const relativePath = filepath.replace(`${basePath}/`, '') - const localizedBasePath = path.posix.join(__dirname, '..', langObj.dir, 'content') // Initialize the Page! This is where the file reads happen. const page = await Page.init({ - basePath: localizedBasePath, + basePath: basePath, relativePath, languageCode: langObj.code }) diff --git a/lib/page-data.js b/lib/page-data.js index fd691224a8..07a21f91ae 100644 --- a/lib/page-data.js +++ b/lib/page-data.js @@ -6,7 +6,6 @@ const createTree = require('./create-tree') const renderContent = require('./render-content') const loadSiteData = require('./site-data') const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version') -const englishPath = path.posix.join(__dirname, '..', 'content') const renderOpts = { textOnly: true, encodeEntities: true } /** @@ -19,7 +18,8 @@ async function loadUnversionedTree () { await Promise.all(Object.values(languages) .map(async (langObj) => { - unversionedTree[langObj.code] = await createTree(englishPath, langObj) + const localizedContentPath = path.posix.join(__dirname, '..', langObj.dir, 'content') + unversionedTree[langObj.code] = await createTree(localizedContentPath, langObj) })) return unversionedTree