--- import GithubSlugger from 'github-slugger'; import DropdownIcon from '@/assets/icons/dropdown-arrow.svg?react'; import type { Guide, Section, SupportedFramework } from '@/types/docs'; import { isSection } from '@/types/docs'; type Props = { item: Guide | Section; framework: SupportedFramework; docTitles: Map; depth?: number; }; const { item, framework, docTitles, depth = 0 } = Astro.props; const currentPath = Astro.url.pathname; const slugger = new GithubSlugger(); // Helper to check if this item or any of its children contains the active path function containsActivePath(item: Guide | Section): boolean { if (isSection(item)) { return item.contents.some((child) => containsActivePath(child)); } else { const itemPath = `/docs/framework/${framework}/${item.slug}`; return itemPath === currentPath; } } const isActive = containsActivePath(item); function getGroup(depth: number) { if (depth === 0) return 'group'; if (depth === 1) return 'group/1'; if (depth === 2) return 'group/2'; return ''; } function getGroupMargin(depth: number) { if (depth === 1) return 'group-open/1:mb-1'; if (depth === 2) return 'group-open/2:mb-1'; return ''; } function getGroupRotate(depth: number) { if (depth === 0) return 'group-open:rotate-180'; if (depth === 1) return 'group-open/1:rotate-180'; if (depth === 2) return 'group-open/2:rotate-180'; return ''; } --- { isSection(item) ? (
0 && "border-l pl-4", isActive ? "border-orange" : "border-manila-75 dark:border-warm-gray", getGroupMargin(depth), ]} style={ depth ? `margin-left: calc(var(--spacing) * ${(depth - 1) * 4})` : `` } > {item.sidebarLabel}
{item.contents.map((contentItem) => ( ))}
) : ( 0 && "border-l pl-4", depth > 0 && isActive && "font-bold", isActive ? "border-orange" : "border-manila-75 dark:border-warm-gray", ]} style={`margin-left: calc(var(--spacing) * ${(depth - 1) * 4})`} href={`/docs/framework/${framework}/${item.slug}`} > {item.devOnly ? "[Dev only] " : ""} {item.sidebarLabel || docTitles.get(item.slug) || item.slug} ) }