add feature flagged middleware
This commit is contained in:
@@ -7,7 +7,7 @@ module.exports = function earlyAccessContext (req, res, next) {
|
||||
|
||||
// Get a list of all hidden pages per version
|
||||
const earlyAccessPageLinks = uniq(Object.values(req.context.pages)
|
||||
.filter(page => page.hidden && page.relativePath.startsWith('early-access') && page.relativePath !== 'early-access/index.md')
|
||||
.filter(page => page.hidden && page.relativePath.startsWith('early-access') && !page.relativePath.endsWith('index.md'))
|
||||
.map(page => page.permalinks)
|
||||
.flat())
|
||||
// Get links for the current version
|
||||
|
||||
@@ -5,16 +5,25 @@ module.exports = function layoutContext (req, res, next) {
|
||||
|
||||
let layoutName
|
||||
|
||||
// If this is an index.md that is not the homepage and does not have a defined layout, use `generic-toc`.
|
||||
const usesGenericToc = req.context.page.relativePath.endsWith('index.md') &&
|
||||
req.context.page.documentType !== 'homepage' &&
|
||||
!req.context.page.hidden
|
||||
|
||||
if (req.context.page.layout) {
|
||||
// Layouts can be specified with a `layout` frontmatter value.
|
||||
// Any invalid layout values will be caught by frontmatter schema validation.
|
||||
layoutName = req.context.page.layout
|
||||
// A `layout: false` value means use no layout.
|
||||
} else if (req.context.page.layout === false) {
|
||||
// A `layout: false` value means use no layout.
|
||||
layoutName = ''
|
||||
// If undefined, use either the default layout or the generic-toc layout.
|
||||
} else if (req.context.page.layout === undefined) {
|
||||
layoutName = 'default'
|
||||
// For all other files (like articles and the homepage), use the `default` layout.
|
||||
if (process.env.FEATURE_NEW_SITETREE) {
|
||||
layoutName = usesGenericToc ? 'generic-toc' : 'default'
|
||||
} else {
|
||||
layoutName = 'default'
|
||||
}
|
||||
}
|
||||
|
||||
// Attach to the context object
|
||||
|
||||
Reference in New Issue
Block a user