Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

precompile.js 977 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  1. const developerRedirects = require('../redirects/static/developer')
  2. const { latest } = require('../../lib/enterprise-server-releases')
  3. const latestDevRedirects = {}
  4. // Replace hardcoded 'latest' with real value in the redirected path
  5. Object.entries(developerRedirects).forEach(([oldPath, newPath]) => {
  6. latestDevRedirects[oldPath] = newPath.replace('enterprise-server@latest', `enterprise-server@${latest}`)
  7. })
  8. // This function runs at server warmup and precompiles possible redirect routes.
  9. // It outputs them in key-value pairs within a neat Javascript object: { oldPath: newPath }
  10. module.exports = async function precompileRedirects (pageList) {
  11. const allRedirects = Object.assign({}, latestDevRedirects)
  12. // CURRENT PAGES PERMALINKS AND FRONTMATTER
  13. // create backwards-compatible old paths for page permalinks and frontmatter redirects
  14. await Promise.all(pageList.map(async (page) => Object.assign(allRedirects, page.buildRedirects())))
  15. return allRedirects
  16. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...