1- const patterns = require ( '../patterns' )
21const { latest } = require ( '../enterprise-server-releases' )
3- const getOldPathsFromPermalink = require ( '../redirects/get-old-paths-from-permalink' )
42const getDocsPathFromDevPath = require ( '../redirects/get-docs-path-from-developer-path' )
53const DEVELOPER_ROUTES = require ( '../redirects/static/developer-docs-routes-for-supported-versions' )
6- const ARCHIVED_ROUTES = require ( '../redirects/static/archived-routes-from-213-to-217' )
74
85// This function runs at server warmup and precompiles possible redirect routes.
96// It outputs them in key-value pairs within a neat Javascript object: { oldPath: newPath }
@@ -14,26 +11,7 @@ module.exports = function precompileRedirects (pageList, pageMap) {
1411 // create backwards-compatible old paths for page permalinks and frontmatter redirects
1512 pageList . forEach ( page => Object . assign ( allRedirects , page . buildRedirects ( ) ) )
1613
17- // 2. REDIRECTS FOR ARCHIVED ROUTES FROM 2.13 TO 2.17
18- // Starting with 2.18, we updated the archival script to create stubbed HTML redirect files,
19- // so those files do the heavy lifting. The handling here is only for blanket redirects
20- // (like /articles -> /github) between 2.13 and 2.17. This works by creating possible
21- // old/incoming paths from the archived routes JSON. Frontmatter redirects were lost
22- // for 2.13-2.17, but the archived middleware tries to find fallbacks.
23- ARCHIVED_ROUTES . forEach ( archivedRoute => {
24- const languageFromPath = archivedRoute . match ( patterns . getLanguageCode ) [ 1 ]
25- const versionFromPath = archivedRoute . match ( patterns . getEnterpriseVersionNumber ) [ 1 ]
26-
27- // get an array of possible old paths, e.g., /desktop/guides/ from /desktop/
28- const possibleOldPaths = getOldPathsFromPermalink ( archivedRoute , languageFromPath , versionFromPath )
29-
30- // for each old path, add a redirect to the current route
31- possibleOldPaths . forEach ( oldPath => {
32- allRedirects [ oldPath ] = archivedRoute
33- } )
34- } )
35-
36- // 3. DEVELOPER ROUTES FOR CURRENTLY SUPPORTED VERSIONS
14+ // 2. DEVELOPER ROUTES FOR CURRENTLY SUPPORTED VERSIONS
3715 // From the list of developer docs routes, create new docs.github.com-style paths.
3816 // Note that the list only includes supported enterprise paths up to 2.21, which is
3917 // the last version that was available on developer.github.com before the migration.
0 commit comments