2021-01-11 20:30:57 +03:00
|
|
|
const getLinkData = require('../lib/get-link-data')
|
2020-09-27 15:10:11 +03:00
|
|
|
|
|
|
|
// 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()
|
|
|
|
|
2020-10-27 20:53:10 +03:00
|
|
|
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)
|
|
|
|
}
|
2020-09-27 15:10:11 +03:00
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|