Skip to content

Commit

Permalink
hide early access product TOC links
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahs committed Jun 29, 2021
1 parent 3ada496 commit a344b8f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions middleware/contextualizers/generic-toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ module.exports = async function genericToc (req, res, next) {
// Find the part of the site tree that corresponds to the current path.
const treePage = findPageInSiteTree(req.context.currentProductTree, req.context.currentEnglishTree, req.pagePath)

// Do not include hidden child items on a TOC page unless it's an Early Access category page.
req.context.showHiddenTocItems = req.context.page.documentType === 'category' && req.context.currentPath.includes('/early-access/')

// Conditionally run getTocItems() recursively.
let isRecursive
// Conditionally render intros.
Expand All @@ -49,8 +52,7 @@ module.exports = async function genericToc (req, res, next) {

async function getTocItems (pagesArray, context, isRecursive, renderIntros) {
return (await Promise.all(pagesArray.map(async (child) => {
// Do not include hidden child items on a TOC page
if (child.page.hidden && !context.currentPath.includes('/early-access/')) return
if (child.page.hidden && !context.showHiddenTocItems) return

return {
title: child.renderedFullTitle,
Expand Down

0 comments on commit a344b8f

Please sign in to comment.