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

whats-new-changelog.js 1.2 KB

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
27
28
29
  1. const { getRssFeed, getChangelogItems } = require('../../lib/changelog')
  2. const getApplicableVersions = require('../../lib/get-applicable-versions')
  3. module.exports = async function whatsNewChangelog (req, res, next) {
  4. if (!req.context.page) return next()
  5. if (!req.context.page.changelog) return next()
  6. const label = req.context.page.changelog.label
  7. // If there is no `versions` prop in the changelog frontmatter, assume the changelog should display in all versions.
  8. if (req.context.page.changelog.versions) {
  9. const changelogVersions = getApplicableVersions(req.context.page.changelog.versions)
  10. // If the current version is not included, do not display a changelog.
  11. if (!changelogVersions.includes(req.context.currentVersion)) {
  12. return next()
  13. }
  14. }
  15. const labelUrls = {
  16. education: 'https://github.blog/category/community/education',
  17. enterprise: 'https://github.blog/category/enterprise/'
  18. }
  19. req.context.changelogUrl = labelUrls[label] || `https://github.blog/changelog/label/${label}`
  20. const feed = await getRssFeed(req.context.changelogUrl)
  21. req.context.whatsNewChangelog = await getChangelogItems(req.context.page.changelog.prefix, feed)
  22. return next()
  23. }
Tip!

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

Comments

Loading...