Populate product-landing "What's new" section using GitHub Changelog (#18328)
Co-authored-by: Jason Etcovitch <jasonetco@github.com> Co-authored-by: Rachael Sewell <rachmari@github.com> Co-authored-by: Sarah Schneider <sarahs@users.noreply.github.com>
This commit is contained in:
13
middleware/contextualizers/whats-new-changelog.js
Normal file
13
middleware/contextualizers/whats-new-changelog.js
Normal file
@@ -0,0 +1,13 @@
|
||||
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()
|
||||
req.context.changelogUrl = req.context.page.changelog.label === 'education'
|
||||
? 'https://github.blog/category/community/education'
|
||||
: `https://github.blog/changelog/label/${req.context.page.changelog.label}`
|
||||
|
||||
const feed = await getRssFeed(req.context.changelogUrl)
|
||||
req.context.whatsNewChangelog = await getChangelogItems(req.context.page.changelog.prefix, feed)
|
||||
return next()
|
||||
}
|
||||
Reference in New Issue
Block a user