make script/dev-toc/generate work like the olden days (#32481)
This commit is contained in:
@@ -36,6 +36,16 @@ async function main() {
|
|||||||
const res = {}
|
const res = {}
|
||||||
const req = { language: 'en', cookies: {} }
|
const req = { language: 'en', cookies: {} }
|
||||||
|
|
||||||
|
async function recurse(tree) {
|
||||||
|
const { page } = tree
|
||||||
|
tree.renderedFullTitle = page.rawTitle.includes('{')
|
||||||
|
? await await liquid.parseAndRender(page.rawTitle, req.context)
|
||||||
|
: page.rawTitle
|
||||||
|
for (const node of tree.childPages || []) {
|
||||||
|
await recurse(node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const version of allVersionKeys) {
|
for (const version of allVersionKeys) {
|
||||||
req.pagePath = version === fpt ? '/' : `/${version}`
|
req.pagePath = version === fpt ? '/' : `/${version}`
|
||||||
|
|
||||||
@@ -52,6 +62,8 @@ async function main() {
|
|||||||
// Add the tree to the req.context.
|
// Add the tree to the req.context.
|
||||||
req.context.currentEnglishTree = req.context.siteTree.en[req.context.currentVersion]
|
req.context.currentEnglishTree = req.context.siteTree.en[req.context.currentVersion]
|
||||||
|
|
||||||
|
await recurse(req.context.currentEnglishTree)
|
||||||
|
|
||||||
// Add any defaultOpenSections to the context.
|
// Add any defaultOpenSections to the context.
|
||||||
req.context.defaultOpenSections = defaultOpenSections
|
req.context.defaultOpenSections = defaultOpenSections
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user