@@ -3,15 +3,34 @@ import type { Response, NextFunction } from 'express'
33import type { ExtendedRequest , Context , Tree , ToC } from '@/types'
44import findPageInSiteTree from '@/frame/lib/find-page-in-site-tree'
55
6+ function isNewLandingPage ( currentLayoutName : string ) : boolean {
7+ return (
8+ currentLayoutName === 'category-landing' ||
9+ currentLayoutName === 'bespoke_landing' ||
10+ currentLayoutName === 'discovery_landing' ||
11+ currentLayoutName === 'journey_landing'
12+ )
13+ }
14+
15+ // TODO: TEMP: This is a temporary solution to turn off/on new landing pages while we develop them.
16+ function isNewLandingPageFeature ( req : ExtendedRequest ) : boolean {
17+ return (
18+ req . query ?. feature === 'bespoke-landing' ||
19+ req . query ?. feature === 'journey-landing' ||
20+ req . query ?. feature === 'discovery-landing'
21+ )
22+ }
23+
624// This module adds either flatTocItems or nestedTocItems to the context object for
725// product, category, and subcategory TOCs that don't have other layouts specified.
826// They are rendered by includes/generic-toc-flat.html or includes/generic-toc-nested.html.
927export default async function genericToc ( req : ExtendedRequest , res : Response , next : NextFunction ) {
1028 if ( ! req . context ) throw new Error ( 'request not contextualized' )
1129 if ( ! req . context . page ) return next ( )
1230 if (
31+ ! isNewLandingPageFeature ( req ) &&
1332 req . context . currentLayoutName !== 'default' &&
14- req . context . currentLayoutName !== 'category-landing'
33+ ! isNewLandingPage ( req . context . currentLayoutName || '' )
1534 )
1635 return next ( )
1736 // This middleware can only run on product, category, and subcategories.
@@ -96,7 +115,10 @@ export default async function genericToc(req: ExtendedRequest, res: Response, ne
96115 renderIntros = false
97116 req . context . genericTocNested = await getTocItems ( treePage , req . context , {
98117 recurse : isRecursive ,
99- renderIntros : req . context . currentLayoutName === 'category-landing' ? true : false ,
118+ renderIntros :
119+ isNewLandingPageFeature ( req ) || isNewLandingPage ( req . context . currentLayoutName || '' )
120+ ? true
121+ : false ,
100122 includeHidden,
101123 } )
102124 }
0 commit comments