diff --git a/src/components/Toc.astro b/src/components/Toc.astro
new file mode 100644
index 0000000..1438c19
--- /dev/null
+++ b/src/components/Toc.astro
@@ -0,0 +1,47 @@
+---
+interface Props {
+ headings: { depth: number; slug: string; text: string }[];
+}
+const { headings } = Astro.props;
+const shown = headings.filter((h) => h.depth <= 3);
+const min = Math.min(...shown.map((h) => h.depth));
+---
+
+
+
+
diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro
index 7328451..f8d56cd 100644
--- a/src/layouts/Base.astro
+++ b/src/layouts/Base.astro
@@ -3,14 +3,17 @@ import 'katex/dist/katex.min.css';
import { getCollection } from 'astro:content';
import { buildNavTree } from '../lib/nav.mjs';
import NavTree from '../components/NavTree.astro';
+import Toc from '../components/Toc.astro';
interface Props {
title: string;
description?: string;
+ headings?: { depth: number; slug: string; text: string }[];
}
-const { title, description } = Astro.props;
+const { title, description, headings = [] } = Astro.props;
const isHome = Astro.url.pathname === '/';
const navTree = buildNavTree(await getCollection('garden'));
+const showToc = headings.filter((h) => h.depth <= 3).length >= 2;
---
@@ -35,6 +38,13 @@ const navTree = buildNavTree(await getCollection('garden'));