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

early-access-links.js 947 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
21
22
23
24
25
26
  1. const { uniq } = require('lodash')
  2. module.exports = function earlyAccessContext (req, res, next) {
  3. if (process.env.NODE_ENV === 'production') {
  4. return next(404)
  5. }
  6. // Get a list of all hidden pages per version
  7. const earlyAccessPageLinks = uniq(Object.values(req.context.pages)
  8. .filter(page => page.hidden && page.relativePath.startsWith('early-access') && !page.relativePath.endsWith('index.md'))
  9. .map(page => page.permalinks)
  10. .flat())
  11. // Get links for the current version
  12. .filter(permalink => req.context.currentVersion === permalink.pageVersion)
  13. .sort()
  14. // Create Markdown links
  15. .map(permalink => `- [${permalink.title}](${permalink.href})`)
  16. // Add to the rendering context
  17. // This is only used in the separate EA repo on local development
  18. req.context.earlyAccessPageLinks = earlyAccessPageLinks.length
  19. ? earlyAccessPageLinks.join('\n')
  20. : '_None for this version!_'
  21. return next()
  22. }
Tip!

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

Comments

Loading...