diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 10:56:21 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 10:56:21 +0300 |
| commit | 456cf011b36de91c9936994b1fa45703adcd309b (patch) | |
| tree | 8e60daf998f731ac50d100fa490eaecae1168042 /src/components/blog/TOC.astro | |
Initial fork of chrismwilliams/astro-theme-cactus theme
Diffstat (limited to 'src/components/blog/TOC.astro')
| -rw-r--r-- | src/components/blog/TOC.astro | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/components/blog/TOC.astro b/src/components/blog/TOC.astro new file mode 100644 index 0000000..6649546 --- /dev/null +++ b/src/components/blog/TOC.astro @@ -0,0 +1,22 @@ +--- +import { generateToc } from "@/utils/generateToc"; +import type { MarkdownHeading } from "astro"; +import TOCHeading from "./TOCHeading.astro"; + +interface Props { + headings: MarkdownHeading[]; +} + +const { headings } = Astro.props; + +const toc = generateToc(headings); +--- + +<details open class="lg:sticky lg:top-12 lg:order-2 lg:-me-32 lg:basis-64"> + <summary class="title hover:marker:text-accent cursor-pointer text-lg">Table of Contents</summary> + <nav class="ms-4 lg:w-full"> + <ol class="mt-4"> + {toc.map((heading) => <TOCHeading heading={heading} />)} + </ol> + </nav> +</details> |
