diff --git a/src/components/widget/TOC.astro b/src/components/widget/TOC.astro index d3c02456..9a3977b9 100644 --- a/src/components/widget/TOC.astro +++ b/src/components/widget/TOC.astro @@ -16,6 +16,8 @@ for (const heading of headings) { const className = Astro.props.class; +const isPostsRoute = Astro.url.pathname.startsWith("/posts/"); + const removeTailingHash = (text: string) => { let lastIndexOfHash = text.lastIndexOf("#"); if (lastIndexOfHash !== text.length - 1) { @@ -29,6 +31,7 @@ let heading1Count = 1; const maxLevel = siteConfig.toc.depth; --- +{isPostsRoute && {headings.filter((heading) => heading.depth < minDepth + maxLevel).map((heading) => - - +}