@@ -6,6 +6,7 @@ const allVersions = Object.keys(require('./all-versions'))
66const { getVersionStringFromPath } = require ( './path-utils' )
77const getApplicableVersions = require ( './get-applicable-versions' )
88const removeFPTFromPath = require ( './remove-fpt-from-path' )
9+ const findPage = require ( './find-page' )
910
1011// This module builds a localized tree of every page on the site
1112// It includes single-source pages that have different variants
@@ -39,7 +40,7 @@ module.exports = async function buildSiteTree (pageMap, site, redirects) {
3940 product . href = path . join ( '/' , languageCode , item . href )
4041
4142 // find the product TOC page so we have access to the TOC items
42- const page = pageMap [ item . href ] || pageMap [ redirects [ item . href ] ]
43+ const page = findPage ( item . href , pageMap , redirects )
4344
4445 // skip if page can't be found in this version
4546 if ( ! page ) return
@@ -74,7 +75,7 @@ function buildCategoriesTree (tocItems, versionedProductHref, pageMap, redirects
7475 category . href = path . join ( versionedProductHref , item . href )
7576
7677 // find the category TOC page and get its TOC items
77- const page = pageMap [ category . href ] || pageMap [ redirects [ category . href ] ]
78+ const page = findPage ( category . href , pageMap , redirects )
7879
7980 // skip if page can't be found in this version
8081 if ( ! page ) return
@@ -118,7 +119,7 @@ function buildMaptopicsTree (tocItems, versionedCategoryHref, pageMap, redirects
118119 maptopic . href = path . join ( versionedCategoryHref , item . href )
119120
120121 // find the category TOC page and get its TOC items
121- const page = pageMap [ maptopic . href ] || pageMap [ redirects [ maptopic . href ] ]
122+ const page = findPage ( maptopic . href , pageMap , redirects )
122123
123124 // skip if page can't be found in this version
124125 if ( ! page ) return
@@ -153,7 +154,7 @@ function buildArticlesTree (tocItems, versionedCategoryHref, pageMap, redirects,
153154 article . href = path . join ( versionedCategoryHref , item . href )
154155
155156 // find the category TOC page and get its TOC items
156- const page = pageMap [ article . href ] || pageMap [ redirects [ article . href ] ]
157+ const page = findPage ( article . href , pageMap , redirects )
157158
158159 // skip if page can't be found in this version
159160 if ( ! page ) return
0 commit comments