@@ -6,11 +6,14 @@ import cx from 'classnames'
66import  {  Link  }  from  '@/frame/components/Link' 
77import  {  useTranslation  }  from  '@/languages/components/useTranslation' 
88import  {  ArticleCardItems ,  ChildTocItem ,  TocItem  }  from  '@/landings/types' 
9+ import  {  LandingType  }  from  '@/landings/context/LandingContext' 
910
1011import  styles  from  './LandingArticleGridWithFilter.module.scss' 
1112
1213type  ArticleGridProps  =  { 
1314 tocItems : TocItem [ ] 
15+  includedCategories ?: string [ ] 
16+  landingType : LandingType 
1417} 
1518
1619const  ALL_CATEGORIES  =  'all_categories' 
@@ -66,7 +69,7 @@ const useResponsiveArticlesPerPage = () => {
6669 return  articlesPerPage 
6770} 
6871
69- export  const  ArticleGrid  =  ( {  tocItems } : ArticleGridProps )  =>  { 
72+ export  const  ArticleGrid  =  ( {  tocItems,  includedCategories ,  landingType  } : ArticleGridProps )  =>  { 
7073 const  {  t }  =  useTranslation ( 'product_landing' ) 
7174 const  [ searchQuery ,  setSearchQuery ]  =  useState ( '' ) 
7275 const  [ selectedCategory ,  setSelectedCategory ]  =  useState ( ALL_CATEGORIES ) 
@@ -83,21 +86,42 @@ export const ArticleGrid = ({ tocItems }: ArticleGridProps) => {
8386 [ tocItems ] , 
8487 ) 
8588
89+  // Filter articles based on includedCategories for discovery landing pages 
90+  // For bespoke landing pages, show all articles regardless of includedCategories 
91+  const  filteredArticlesByLandingType  =  useMemo ( ( )  =>  { 
92+  if  ( landingType  ===  'discovery'  &&  includedCategories  &&  includedCategories . length  >  0 )  { 
93+  // For discovery pages, only include articles that have at least one matching category 
94+  return  allArticles . filter ( ( article )  =>  { 
95+  if  ( ! article . category  ||  article . category . length  ===  0 )  return  false 
96+  return  article . category . some ( ( cat )  => 
97+  includedCategories . some ( ( included )  =>  included . toLowerCase ( )  ===  cat . toLowerCase ( ) ) , 
98+  ) 
99+  } ) 
100+  } 
101+  // For bespoke pages or when includedCategories is empty/undefined, return all articles 
102+  return  allArticles 
103+  } ,  [ allArticles ,  includedCategories ,  landingType ] ) 
104+ 
86105 // Reset to first page when articlesPerPage changes (screen size changes) 
87106 useEffect ( ( )  =>  { 
88107 setCurrentPage ( 1 ) 
89108 } ,  [ articlesPerPage ] ) 
90109
91-  // Extract unique categories from the articles 
110+  // Extract unique categories from the filtered  articles, filtering dropdown by includedCategories if provided  
92111 const  categories : string [ ]  =  [ 
93112 ALL_CATEGORIES , 
94-  ...Array . from ( new  Set ( allArticles . flatMap ( ( item )  =>  item . category  ||  [ ] ) ) ) . sort ( ( a ,  b )  => 
95-  a . localeCompare ( b ) , 
96-  ) , 
113+  ...Array . from ( new  Set ( filteredArticlesByLandingType . flatMap ( ( item )  =>  item . category  ||  [ ] ) ) ) 
114+  . filter ( ( category )  =>  { 
115+  if  ( ! includedCategories  ||  includedCategories . length  ===  0 )  return  true 
116+  // Case-insensitive comparison for dropdown filtering 
117+  const  lowerCategory  =  category . toLowerCase ( ) 
118+  return  includedCategories . some ( ( included )  =>  included . toLowerCase ( )  ===  lowerCategory ) 
119+  } ) 
120+  . sort ( ( a ,  b )  =>  a . localeCompare ( b ) ) , 
97121 ] 
98122
99123 const  applyFilters  =  ( )  =>  { 
100-  let  results  =  allArticles 
124+  let  results  =  filteredArticlesByLandingType 
101125
102126 if  ( searchQuery )  { 
103127 results  =  results . filter ( ( token )  =>  { 
0 commit comments