summaryrefslogtreecommitdiff
path: root/src/components/blog/TOCHeading.astro
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-07-03 10:56:21 +0300
committerDawid Rycerz <dawid@rycerz.xyz>2025-07-03 10:56:21 +0300
commit456cf011b36de91c9936994b1fa45703adcd309b (patch)
tree8e60daf998f731ac50d100fa490eaecae1168042 /src/components/blog/TOCHeading.astro
Initial fork of chrismwilliams/astro-theme-cactus theme
Diffstat (limited to 'src/components/blog/TOCHeading.astro')
-rw-r--r--src/components/blog/TOCHeading.astro27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/components/blog/TOCHeading.astro b/src/components/blog/TOCHeading.astro
new file mode 100644
index 0000000..b9dd486
--- /dev/null
+++ b/src/components/blog/TOCHeading.astro
@@ -0,0 +1,27 @@
+---
+import type { TocItem } from "@/utils/generateToc";
+
+interface Props {
+ heading: TocItem;
+}
+
+const {
+ heading: { children, depth, slug, text },
+} = Astro.props;
+---
+
+<li class={`${depth > 2 ? "ms-2" : ""}`}>
+ <a
+ class={`line-clamp-2 hover:text-accent ${depth <= 2 ? "mt-3" : "mt-2 text-xs"}`}
+ href={`#${slug}`}><span aria-hidden="true" class="me-0.5">#</span>{text}</a
+ >
+ {
+ !!children.length && (
+ <ol>
+ {children.map((subheading) => (
+ <Astro.self heading={subheading} />
+ ))}
+ </ol>
+ )
+ }
+</li>