--- // Menu tree from shared/data/docs.json. import Subheader from '@ui/Subheader.astro' import docs from '@data/docs.json' import { pathSlug as slug } from '@shared/lib/string-format' interface MenuLeaf { title: string url: string } interface MenuGroup { title: string /** omitted for groups that only label a set of pages, with no index page of their own */ url?: string children?: MenuLeaf[] } interface MenuSection { title: string children?: MenuGroup[] } interface Props { /** Page URL in the docs namespace, e.g. "/ui/components/alert". */ url: string } const { url } = Astro.props const menu = docs.menu as MenuSection[] /** Collapse target: from the group's url, or from its title when it has none. */ const groupId = (group: MenuGroup) => `collapse-${slug(group.url ?? group.title) .toLowerCase() .replace(/[^a-z0-9-]+/g, '-')}` ---