1
0
mirror of synced 2025-12-25 02:17:36 -05:00

add comments

This commit is contained in:
Sarah Schneider
2021-05-28 19:53:03 -04:00
parent 6baeaff8e1
commit 02915d5e4e

View File

@@ -1,11 +1,13 @@
const getApplicableVersions = require('../../lib/get-applicable-versions')
module.exports = async function breadcrumbs (req, res, next) {
module.exports = async function features (req, res, next) {
if (!req.context.page) return next()
// Determine whether the currentVersion belongs to the list of versions the feature is available in.
Object.keys(req.context.site.data.features).forEach(featureName => {
const { versions } = req.context.site.data.features[featureName]
const applicableVersions = getApplicableVersions(versions, req.path)
// Adding this to the context object gives us the ability to use `{% if foo %}` conditionals in content files.
req.context[featureName] = applicableVersions.includes(req.context.currentVersion)
})