---
interface Heading {
depth: number;
slug: string;
text: string;
}
interface Props {
headings: Heading[];
}
const { headings = [] } = Astro.props;
// 只取 h2 / h3,博客目录最常见
const tocHeadings = headings.filter((h) => h.depth === 2 || h.depth === 3);
// 手机端按钮里显示的“目录: 第一节、xxxxx”
const mobilePreview = tocHeadings[0]?.text ?? "本文目录";
---
{
tocHeadings.length > 0 && (
<>
>
)
}