22import { Sections } from " ~/content.config"
33import { SIDEBAR } from " ../../config"
44import type { SectionEntry , SectionContent } from " ../../config"
5+ import { SIDEBAR_SECTIONS } from " ../../config/sidebarSections.ts"
6+ import { AI_AGENT_RESOURCES_SECTION , withParentQuery } from " ../../config/sidebar/ai-agent-resources.ts"
57import RecursiveSidebar from " ./RecursiveSidebar.astro"
68import { LanguageSwitcherDropdown } from " ~/components/LanguageSwitcherDropdown"
79import { ChainTypeSelector } from " ~/components/ChainSelector"
@@ -12,6 +14,9 @@ import styles from "./leftSidebar.module.css"
1214
1315type SectionEntryWithParent = SectionEntry & { parentSection? : string }
1416
17+ /** Product sidebars that should not duplicate the shared AI resources footer. */
18+ const SECTIONS_WITHOUT_AI_RESOURCES = new Set <Sections >([SIDEBAR_SECTIONS .GLOBAL , SIDEBAR_SECTIONS .LEGACY ])
19+
1520export type Props = {
1621 currentPage: string
1722 section? : Sections
@@ -27,12 +32,28 @@ function getSidebarSections(section?: Sections): SectionEntryWithParent[] {
2732 if (! section ) {
2833 return []
2934 } else if (section === " global" ) {
30- // Flatten all sidebar entries into one array
35+ // Flatten all sidebar entries into one array (include AI resources per product)
3136 return Object .entries (SIDEBAR ).flatMap (([parentSection , entries ]) => {
32- return entries ?.map ((entry ) => ({ ... entry , parentSection })) ?? []
37+ const sections = entries ?.map ((entry ) => ({ ... entry , parentSection: parentSection as Sections })) ?? []
38+
39+ if (! SECTIONS_WITHOUT_AI_RESOURCES .has (parentSection as Sections )) {
40+ sections .push ({
41+ ... withParentQuery (AI_AGENT_RESOURCES_SECTION , parentSection as Sections ),
42+ parentSection: parentSection as Sections ,
43+ })
44+ }
45+
46+ return sections
3347 })
3448 }
35- return SIDEBAR [section ] ?? []
49+
50+ const productSections = SIDEBAR [section ] ?? []
51+
52+ if (SECTIONS_WITHOUT_AI_RESOURCES .has (section )) {
53+ return productSections
54+ }
55+
56+ return [... productSections , withParentQuery (AI_AGENT_RESOURCES_SECTION , section )]
3657}
3758
3859/**
0 commit comments