Skip to content

Commit 35b938a

Browse files
committed
no longer need to precompile developer redirects now that we have the static redirects file
1 parent efa186c commit 35b938a

1 file changed

Lines changed: 4 additions & 31 deletions

File tree

lib/redirects/precompile.js

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,13 @@
1-
const { latest } = require('../enterprise-server-releases')
2-
const getDocsPathFromDevPath = require('../redirects/get-docs-path-from-developer-path')
3-
const DEVELOPER_ROUTES = require('../redirects/static/developer-docs-routes-for-supported-versions')
1+
const developerRedirects = require('../redirects/static/developer')
42

53
// This function runs at server warmup and precompiles possible redirect routes.
64
// It outputs them in key-value pairs within a neat Javascript object: { oldPath: newPath }
7-
module.exports = function precompileRedirects (pageList, pageMap) {
8-
const allRedirects = {}
5+
module.exports = function precompileRedirects (pageList) {
6+
const allRedirects = Object.assign({}, developerRedirects)
97

10-
// 1. CURRENT PAGES PERMALINKS AND FRONTMATTER
8+
// CURRENT PAGES PERMALINKS AND FRONTMATTER
119
// create backwards-compatible old paths for page permalinks and frontmatter redirects
1210
pageList.forEach(page => Object.assign(allRedirects, page.buildRedirects()))
1311

14-
// 2. DEVELOPER ROUTES FOR CURRENTLY SUPPORTED VERSIONS
15-
// From the list of developer docs routes, create new docs.github.com-style paths.
16-
// Note that the list only includes supported enterprise paths up to 2.21, which is
17-
// the last version that was available on developer.github.com before the migration.
18-
DEVELOPER_ROUTES.forEach(developerRoute => {
19-
const newPath = getDocsPathFromDevPath(developerRoute, allRedirects, pageMap)
20-
21-
// add the redirect to the object
22-
allRedirects[developerRoute] = newPath
23-
24-
// also add a variation with language code
25-
const developerRouteWithLanguage = `/en${developerRoute}`
26-
allRedirects[developerRouteWithLanguage] = newPath
27-
28-
// although we only support developer Enterprise paths up to 2.21, we make
29-
// an exception to always redirect versionless paths to the latest version
30-
if (developerRoute.includes('/2.21/')) {
31-
const newPathOnLatestVersion = newPath.replace('@2.21/', `@${latest}/`)
32-
const developerRouteWithoutVersion = developerRoute.replace('/2.21/', '/')
33-
const developerRouteWithLanguageWithoutVersion = `/en${developerRouteWithoutVersion}`
34-
allRedirects[developerRouteWithoutVersion] = newPathOnLatestVersion
35-
allRedirects[developerRouteWithLanguageWithoutVersion] = newPathOnLatestVersion
36-
}
37-
})
38-
3912
return allRedirects
4013
}

0 commit comments

Comments
 (0)