--- import { getCategoryHref, type BlogPost } from '@/lib/posts'; import SiteInfoCard from '@/components/SiteInfoCard.astro'; import { siteConfig } from '../../site.config.mjs'; type TocItem = { depth: number; text: string; id: string; }; type TocSection = { heading: TocItem; children: TocItem[]; }; interface Props { post: BlogPost; toc: TocItem[]; relatedPosts: BlogPost[]; posts: BlogPost[]; } const { post, toc, relatedPosts, posts } = Astro.props; const avatar = siteConfig.author.avatar; const topDepth = toc.length > 0 ? Math.min(...toc.map((item) => item.depth)) : 1; const tocSections = toc.reduce((sections, item) => { if (item.depth <= topDepth || sections.length === 0) { sections.push({ heading: item, children: [] }); } else { sections[sections.length - 1].children.push(item); } return sections; }, []); ---