Skip to content

Commit 9bb36a1

Browse files
sarahsgracepark
andauthored
remove Insights-specific logic and update comment (github#26483)
Co-authored-by: Grace Park <[email protected]>
1 parent ae85724 commit 9bb36a1

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

middleware/contextualizers/generic-toc.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ export default async function genericToc(req, res, next) {
3030
req.pagePath
3131
)
3232

33-
// Do not include hidden child items on a TOC page unless it's an Early Access category page.
34-
// We need to account for the extra 'articles' segment with Early Access as well, we don't
35-
// want to show hidden child items in that case.
36-
req.context.showHiddenTocItems =
37-
(req.context.page.documentType === 'category' &&
38-
req.context.currentPath.includes('/early-access/') &&
39-
!req.context.currentPath.endsWith('/articles')) ||
40-
(req.context.page.documentType === 'product' &&
41-
req.context.currentPath.includes('/early-access/') &&
42-
req.context.page.shortTitle === 'GitHub Insights')
33+
// Only include hidden child items on a TOC page if it's an Early Access category or
34+
// map topic page, not a product or 'articles' fake cagegory page (e.g., /early-access/github/articles).
35+
// This is because we don't want entire EA product TOCs to be publicly browseable, but anything at the category
36+
// or below level is fair game because that content is scoped to specific features.
37+
const isCategoryOrMapTopic =
38+
req.context.page.documentType === 'category' || req.context.page.documentType === 'mapTopic'
39+
const isEarlyAccess = req.context.currentPath.includes('/early-access/')
40+
const isArticlesCategory = req.context.currentPath.endsWith('/articles')
41+
42+
req.context.showHiddenTocItems = isCategoryOrMapTopic && isEarlyAccess && !isArticlesCategory
4343

4444
// Conditionally run getTocItems() recursively.
4545
let isRecursive
@@ -77,6 +77,7 @@ async function getTocItems(pagesArray, context, isRecursive, renderIntros) {
7777
return (
7878
await Promise.all(
7979
pagesArray.map(async (child) => {
80+
// only include a hidden page if showHiddenTocItems is true
8081
if (child.page.hidden && !context.showHiddenTocItems) return
8182

8283
return {

0 commit comments

Comments
 (0)