add anchor links

This commit is contained in:
Felix Roos 2024-01-14 23:30:26 +01:00
parent c02976782b
commit 98db3d37ef
2 changed files with 8 additions and 2 deletions

View File

@ -12,7 +12,7 @@ const { Content } = await post.render();
>
<div class="pb-2">
<div class="md:flex justify-between">
<h1 class="mb-4">{post.title}</h1>
<h1 class="mb-4" id={post.slug}>{post.title}</h1>
</div>
</div>
<div>

View File

@ -36,7 +36,13 @@ const posts = (await getCollection('blog')).sort((a, b) => compareDesc(a.data.da
{posts.map((post) => <BlogPost post={post} />)}
</PageContent>
<aside class="fixed right-0 h-full overflow-auto pr-4 pl-0 pb-16 hidden xl:block" title="Table of Contents">
<RightSidebar headings={[]} />
<RightSidebar
headings={posts.map((post) => ({
depth: 1,
slug: post.slug,
text: post.data.title,
}))}
/>
</aside>
</div>
</main>