@@ -14,7 +14,7 @@ const allVersions = Object.keys(require('./all-versions'))
1414// or if a category has direct child articles:
1515// siteTree[languageCode][version].products[productHref].categories[categoryHref].articles
1616
17- module . exports = async function buildSiteTree ( pages , site , redirects ) {
17+ module . exports = async function buildSiteTree ( pageMap , site , redirects ) {
1818 const siteTree = { }
1919
2020 languageCodes . forEach ( languageCode => {
@@ -38,12 +38,12 @@ module.exports = async function buildSiteTree (pages, site, redirects) {
3838 product . href = item . href
3939
4040 // find the product TOC page and get TOC items
41- const page = findPageInVersion ( item . href , pages , redirects , languageCode , version )
41+ const page = findPageInVersion ( item . href , pageMap , redirects , languageCode , version )
4242
4343 // skip if page can't be found in this version
4444 if ( ! page ) return
4545
46- product . categories = buildCategoriesTree ( page . tocItems , item . href , pages , redirects , version , languageCode )
46+ product . categories = buildCategoriesTree ( page . tocItems , item . href , pageMap , redirects , version , languageCode )
4747
4848 productTree [ item . id ] = product
4949 return null
@@ -58,7 +58,7 @@ module.exports = async function buildSiteTree (pages, site, redirects) {
5858 return siteTree
5959}
6060
61- function buildCategoriesTree ( tocItems , productHref , pages , redirects , version , languageCode ) {
61+ function buildCategoriesTree ( tocItems , productHref , pageMap , redirects , version , languageCode ) {
6262 const categoryTree = { }
6363
6464 // for every category in a product TOC...
@@ -71,7 +71,7 @@ function buildCategoriesTree (tocItems, productHref, pages, redirects, version,
7171 category . href = versionedCategoryHref
7272
7373 // find the category TOC page and get its TOC items
74- const page = findPageInVersion ( categoryHref , pages , redirects , languageCode , version )
74+ const page = findPageInVersion ( categoryHref , pageMap , redirects , languageCode , version )
7575
7676 // skip if page can't be found in this version
7777 if ( ! page ) return
@@ -90,9 +90,9 @@ function buildCategoriesTree (tocItems, productHref, pages, redirects, version,
9090 // if TOC contains maptopics, build a maptopics tree
9191 // otherwise build an articles tree
9292 if ( hasMaptopics ) {
93- category . maptopics = buildMaptopicsTree ( page . tocItems , categoryHref , pages , redirects , version , languageCode )
93+ category . maptopics = buildMaptopicsTree ( page . tocItems , categoryHref , pageMap , redirects , version , languageCode )
9494 } else {
95- category . articles = buildArticlesTree ( page . tocItems , categoryHref , pages , redirects , version , languageCode )
95+ category . articles = buildArticlesTree ( page . tocItems , categoryHref , pageMap , redirects , version , languageCode )
9696 }
9797 }
9898
@@ -102,7 +102,7 @@ function buildCategoriesTree (tocItems, productHref, pages, redirects, version,
102102 return categoryTree
103103}
104104
105- function buildMaptopicsTree ( tocItems , categoryHref , pages , redirects , version , languageCode ) {
105+ function buildMaptopicsTree ( tocItems , categoryHref , pageMap , redirects , version , languageCode ) {
106106 const maptopicTree = { }
107107
108108 // for every maptopic in a category TOC...
@@ -118,7 +118,7 @@ function buildMaptopicsTree (tocItems, categoryHref, pages, redirects, version,
118118
119119 // we already have access to the child articles via the category TOC items
120120 // but we still need the page to get the available versions
121- const page = findPageInVersion ( maptopicHref , pages , redirects , languageCode , version )
121+ const page = findPageInVersion ( maptopicHref , pageMap , redirects , languageCode , version )
122122
123123 // skip if page can't be found in this version
124124 if ( ! page ) return
@@ -135,14 +135,14 @@ function buildMaptopicsTree (tocItems, categoryHref, pages, redirects, version,
135135 // make the child articles accessible to the page object for maptopic rendering
136136 if ( ! page . childArticles ) page . childArticles = childArticles
137137
138- maptopic . articles = buildArticlesTree ( childArticles , categoryHref , pages , redirects , version , languageCode )
138+ maptopic . articles = buildArticlesTree ( childArticles , categoryHref , pageMap , redirects , version , languageCode )
139139 maptopicTree [ versionedMaptopicHref ] = maptopic
140140 } )
141141
142142 return maptopicTree
143143}
144144
145- function buildArticlesTree ( tocItems , categoryHref , pages , redirects , version , languageCode ) {
145+ function buildArticlesTree ( tocItems , categoryHref , pageMap , redirects , version , languageCode ) {
146146 const articleTree = { }
147147
148148 // REST categories may not have TOC items
@@ -157,7 +157,7 @@ function buildArticlesTree (tocItems, categoryHref, pages, redirects, version, l
157157 const versionedArticleHref = getVersionedPathWithoutLanguage ( articleHref , version )
158158 article . href = versionedArticleHref
159159
160- const page = findPageInVersion ( articleHref , pages , redirects , languageCode , version )
160+ const page = findPageInVersion ( articleHref , pageMap , redirects , languageCode , version )
161161
162162 // skip if page can't be found in this version
163163 if ( ! page ) return
0 commit comments