1
0
mirror of synced 2025-12-23 11:54:18 -05:00
Files
docs/middleware/featured-links.js
Vanessa Yuen 641ed02e81 Actions Guides sublanding page (#16740)
Co-authored-by: Emily Gould <4822039+emilyistoofunky@users.noreply.github.com>
Co-authored-by: Cynthia Rich <crichID@github.com>
2021-01-11 18:30:57 +01:00

18 lines
589 B
JavaScript

const getLinkData = require('../lib/get-link-data')
// this middleware adds properties to the context object
module.exports = async (req, res, next) => {
if (!req.context.page) return next()
if (!(req.context.page.relativePath.endsWith('index.md') || req.context.page.layout === 'product-landing')) return next()
if (!req.context.page.featuredLinks) return next()
req.context.featuredLinks = {}
for (const key in req.context.page.featuredLinks) {
req.context.featuredLinks[key] = await getLinkData(req.context.page.featuredLinks[key], req.context)
}
return next()
}