MCPcopy Index your code
hub / github.com/github/docs / versionPages

Function versionPages

lib/page-data.js:222–242  ·  view source on GitHub ↗
(obj, version, langCode)

Source from the content-addressed store, hash-verified

220}
221
222export async function versionPages(obj, version, langCode) {
223 // Add a versioned href as a convenience for use in layouts.
224 obj.href = obj.page.permalinks.find(
225 (pl) =>
226 pl.pageVersion === version ||
227 (pl.pageVersion === 'homepage' && version === nonEnterpriseDefaultVersion)
228 ).href
229
230 if (!obj.childPages) return obj
231 const versionedChildPages = await Promise.all(
232 obj.childPages
233 // Drop child pages that do not apply to the current version
234 .filter((childPage) => childPage.page.applicableVersions.includes(version))
235 // Version the child pages recursively.
236 .map((childPage) => versionPages(Object.assign({}, childPage), version, langCode))
237 )
238
239 obj.childPages = [...versionedChildPages]
240
241 return obj
242}
243
244// Derive a flat array of Page objects in all languages.
245export async function loadPageList(unversionedTree, languagesOnly = null) {

Callers 1

loadSiteTreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected