1
0
mirror of synced 2025-12-23 11:54:18 -05:00
Files
docs/lib/get-map-topic-content.js
2020-12-14 16:53:04 -05:00

23 lines
690 B
JavaScript

const findPage = require('./find-page')
// get the page.childArticles set on english map topics in lib/site-tree.js
module.exports = function getMapTopicContent (page, pageMap, redirects) {
const englishPage = page.languageCode !== 'en'
? findPage(`/${page.relativePath.replace(/.md$/, '')}`, pageMap, redirects, 'en')
: page
if (!englishPage) {
console.error(`cannot find english page: ${page.fullPath}`)
return
}
if (!englishPage.childArticles) {
console.error(`error getting child articles on map topic: ${page.fullPath}`)
return
}
return englishPage.childArticles
.map(article => `{% link_with_intro /${article.href} %}`)
.join('\n\n')
}