feat: corrects md to use a manual slug

This commit is contained in:
Lewis Wynne 2026-01-31 00:04:54 +00:00
parent 9a40597b1f
commit df12debd4c
3 changed files with 3 additions and 2 deletions

View file

@ -11,6 +11,7 @@ const posts = defineCollection({
pinned: z.boolean().optional(),
category: z.string().optional(),
draft: z.boolean().optional(),
slug: z.string(),
})
});

View file

@ -5,7 +5,7 @@ import Layout from '../../layouts/Layout.astro';
export async function getStaticPaths() {
const posts = await getCollection('posts', ({ data }) => data.draft !== true);
return posts.map(post => ({
params: { slug: post.id },
params: { slug: post.data.slug },
props: { post }
}));
}

View file

@ -40,7 +40,7 @@ function formatDate(date: Date): string {
{sortedCategories.map(category => (
<details open>
<summary>{category}</summary>
<pre set:html={grouped[category].map(post => `<span class="muted">${formatDate(post.data.date)}</span> <a href="/md/${post.id}">${post.data.title}</a>${post.data.pinned ? ' [pinned]' : ''}`).join('\n')} />
<pre set:html={grouped[category].map(post => `<span class="muted">${formatDate(post.data.date)}</span> <a href="/md/${post.data.slug}">${post.data.title}</a>${post.data.pinned ? ' [pinned]' : ''}`).join('\n')} />
</details>
))}
</Layout>