@@ -164,9 +164,38 @@ function shouldExpandSection(item: SectionContent, currentPage: string): boolean
164164</ul >
165165
166166<script >
167+ /**
168+ * Unified filter that checks BOTH language AND chain type criteria
169+ * This prevents one filter from overwriting the other's display property
170+ */
171+ function shouldShowSidebarItem(item: HTMLElement, currentLang: string, currentChain?: string): boolean {
172+ // Check language filter
173+ const sdkLang = item.getAttribute("data-sdk-lang")
174+ const langVisible =
175+ sdkLang === "both" || // Always show language-agnostic items
176+ !sdkLang || // Items without sdkLang attribute
177+ sdkLang === currentLang // Matches current language
178+
179+ // Check chain type filter (only if chain filtering is active)
180+ let chainVisible = true
181+ if (currentChain) {
182+ const chainTypesAttr = item.getAttribute("data-chain-types")
183+ if (chainTypesAttr === "universal" || !chainTypesAttr) {
184+ chainVisible = true // Always show universal/legacy content
185+ } else {
186+ const itemChains = chainTypesAttr.split(",")
187+ chainVisible = itemChains.includes(currentChain)
188+ }
189+ }
190+
191+ // Item is visible only if BOTH filters pass
192+ return langVisible && chainVisible
193+ }
194+
167195 /**
168196 * Filters sidebar items based on selected SDK language
169197 * - Hides items with data-sdk-lang that don't match current selection
198+ * - Respects chain type filtering if active
170199 * - Runs on initial load and when language changes
171200 */
172201 function filterSidebarByLanguage() {
@@ -181,22 +210,23 @@ function shouldExpandSection(item: SectionContent, currentPage: string): boolean
181210 // Fallback to default
182211 }
183212
213+ // Get current chain type if chain filtering is active (for CCIP section)
214+ let currentChain: string | undefined
215+ try {
216+ const chainStore = localStorage.getItem("chainlink-docs-chain-type")
217+ if (chainStore) {
218+ currentChain = chainStore
219+ }
220+ } catch {
221+ // Chain filtering not active in this section
222+ }
223+
184224 // Find all sidebar items with data-sdk-lang attribute
185225 const sidebarItems = document.querySelectorAll<HTMLElement>("[data-sdk-lang]")
186226
187227 sidebarItems.forEach((item) => {
188- const sdkLang = item.getAttribute("data-sdk-lang")
189-
190- if (sdkLang === "both") {
191- // Always show items that are language-agnostic
192- item.style.display = ""
193- } else if (sdkLang !== currentLang) {
194- // Hide items that don't match current language
195- item.style.display = "none"
196- } else {
197- // Show items that match current language
198- item.style.display = ""
199- }
228+ const visible = shouldShowSidebarItem(item, currentLang, currentChain)
229+ item.style.display = visible ? "" : "none"
200230 })
201231 }
202232
0 commit comments