File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,19 +2,19 @@ const developerRedirects = require('../redirects/static/developer')
22const { latest } = require ( '../../lib/enterprise-server-releases' )
33const latestDevRedirects = { }
44
5- // Replace hardcoded 'latest' with real value
5+ // Replace hardcoded 'latest' with real value in the redirected path
66Object . entries ( developerRedirects ) . forEach ( ( [ oldPath , newPath ] ) => {
77 latestDevRedirects [ oldPath ] = newPath . replace ( 'enterprise-server@latest' , `enterprise-server@${ latest } ` )
88} )
99
1010// This function runs at server warmup and precompiles possible redirect routes.
1111// It outputs them in key-value pairs within a neat Javascript object: { oldPath: newPath }
12- module . exports = function precompileRedirects ( pageList ) {
12+ module . exports = async function precompileRedirects ( pageList ) {
1313 const allRedirects = Object . assign ( { } , latestDevRedirects )
1414
1515 // CURRENT PAGES PERMALINKS AND FRONTMATTER
1616 // create backwards-compatible old paths for page permalinks and frontmatter redirects
17- pageList . forEach ( page => Object . assign ( allRedirects , page . buildRedirects ( ) ) )
17+ await Promise . all ( pageList . map ( async ( page ) => Object . assign ( allRedirects , page . buildRedirects ( ) ) ) )
1818
1919 return allRedirects
2020}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const loadSiteTree = require('./site-tree')
99const dog = {
1010 loadPages : statsd . asyncTimer ( loadPages , 'load_pages' ) ,
1111 loadPageMap : statsd . asyncTimer ( loadPageMap , 'load_page_map' ) ,
12- loadRedirects : statsd . timer ( loadRedirects , 'load_redirects' ) ,
12+ loadRedirects : statsd . asyncTimer ( loadRedirects , 'load_redirects' ) ,
1313 loadSiteData : statsd . timer ( loadSiteData , 'load_site_data' ) ,
1414 loadSiteTree : statsd . asyncTimer ( loadSiteTree , 'load_site_tree' )
1515}
@@ -52,7 +52,7 @@ async function warmServer () {
5252 }
5353
5454 if ( ! redirects ) {
55- redirects = dog . loadRedirects ( pageList , pageMap )
55+ redirects = await dog . loadRedirects ( pageList , pageMap )
5656 }
5757
5858 if ( ! siteTree ) {
You can’t perform that action at this time.
0 commit comments