This commit is contained in:
Sarah Schneider 2021-02-26 13:23:50 -05:00
Родитель 7563adce8a
Коммит 2c8902f826
2 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -2,19 +2,19 @@ const developerRedirects = require('../redirects/static/developer')
const { latest } = require('../../lib/enterprise-server-releases') const { latest } = require('../../lib/enterprise-server-releases')
const latestDevRedirects = {} const latestDevRedirects = {}
// Replace hardcoded 'latest' with real value // Replace hardcoded 'latest' with real value in the redirected path
Object.entries(developerRedirects).forEach(([oldPath, newPath]) => { Object.entries(developerRedirects).forEach(([oldPath, newPath]) => {
latestDevRedirects[oldPath] = newPath.replace('enterprise-server@latest', `enterprise-server@${latest}`) latestDevRedirects[oldPath] = newPath.replace('enterprise-server@latest', `enterprise-server@${latest}`)
}) })
// This function runs at server warmup and precompiles possible redirect routes. // This function runs at server warmup and precompiles possible redirect routes.
// It outputs them in key-value pairs within a neat Javascript object: { oldPath: newPath } // It outputs them in key-value pairs within a neat Javascript object: { oldPath: newPath }
module.exports = function precompileRedirects (pageList) { module.exports = async function precompileRedirects (pageList) {
const allRedirects = Object.assign({}, latestDevRedirects) const allRedirects = Object.assign({}, latestDevRedirects)
// CURRENT PAGES PERMALINKS AND FRONTMATTER // CURRENT PAGES PERMALINKS AND FRONTMATTER
// create backwards-compatible old paths for page permalinks and frontmatter redirects // create backwards-compatible old paths for page permalinks and frontmatter redirects
pageList.forEach(page => Object.assign(allRedirects, page.buildRedirects())) await Promise.all(pageList.map(async(page) => Object.assign(allRedirects, page.buildRedirects())))
return allRedirects return allRedirects
} }

Просмотреть файл

@ -9,7 +9,7 @@ const loadSiteTree = require('./site-tree')
const dog = { const dog = {
loadPages: statsd.asyncTimer(loadPages, 'load_pages'), loadPages: statsd.asyncTimer(loadPages, 'load_pages'),
loadPageMap: statsd.asyncTimer(loadPageMap, 'load_page_map'), loadPageMap: statsd.asyncTimer(loadPageMap, 'load_page_map'),
loadRedirects: statsd.timer(loadRedirects, 'load_redirects'), loadRedirects: statsd.asyncTimer(loadRedirects, 'load_redirects'),
loadSiteData: statsd.timer(loadSiteData, 'load_site_data'), loadSiteData: statsd.timer(loadSiteData, 'load_site_data'),
loadSiteTree: statsd.asyncTimer(loadSiteTree, 'load_site_tree') loadSiteTree: statsd.asyncTimer(loadSiteTree, 'load_site_tree')
} }
@ -52,7 +52,7 @@ async function warmServer () {
} }
if (!redirects) { if (!redirects) {
redirects = dog.loadRedirects(pageList, pageMap) redirects = await dog.loadRedirects(pageList, pageMap)
} }
if (!siteTree) { if (!siteTree) {