1
0
mirror of synced 2025-12-21 19:06:49 -05:00
Files
docs/middleware/contextualizers/whats-new-changelog.js
2021-05-12 11:55:32 +00:00

19 lines
706 B
JavaScript

const { getRssFeed, getChangelogItems } = require('../../lib/changelog')
module.exports = async function whatsNewChangelog (req, res, next) {
if (!req.context.page) return next()
if (!req.context.page.changelog) return next()
const label = req.context.page.changelog.label
const labelUrls = {
education: 'https://github.blog/category/community/education',
enterprise: 'https://github.blog/category/enterprise/'
}
req.context.changelogUrl = labelUrls[label] || `https://github.blog/changelog/label/${label}`
const feed = await getRssFeed(req.context.changelogUrl)
req.context.whatsNewChangelog = await getChangelogItems(req.context.page.changelog.prefix, feed)
return next()
}