From 9ced1cff53439ae245e44cc86a2b092fb497d983 Mon Sep 17 00:00:00 2001 From: edo999 Date: Sat, 25 Jan 2025 17:14:55 +0000 Subject: [PATCH] =?UTF-8?q?Add=20a=20TOC=20to=20the=20slash=20pages=20?= =?UTF-8?q?=F0=9F=93=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/[...id].astro | 42 +++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/pages/[...id].astro b/src/pages/[...id].astro index fb8921b..86b419c 100644 --- a/src/pages/[...id].astro +++ b/src/pages/[...id].astro @@ -12,23 +12,37 @@ export const getStaticPaths = async () => { } const { title, description } = Astro.props.post.data -const { Content } = await render(Astro.props.post) +const { Content, headings } = await render(Astro.props.post) + +const toc = headings.filter((heading) => heading.depth === 2) --- -
-
-

- {title} -

-

- {description} -

-
-
- +
+

+ {title} +

+ +
+
    + { + toc.map(({ slug, text }) => ( +
  • + + {text} + +
  • + )) + } +
+
+ +