1
0
mirror of synced 2025-12-21 10:57:10 -05:00
Files
docs/middleware/featured-links.js
Kevin Heis 8a56437c93 Pretty format (#20352)
* Update prettier flow to include JS

* Run prettier

* ...run prettier
2021-07-14 14:35:01 -07:00

27 lines
652 B
JavaScript

import getLinkData from '../lib/get-link-data.js'
// this middleware adds properties to the context object
export default async function featuredLinks(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()
}