feat: corrects md to use a manual slug
This commit is contained in:
parent
9a40597b1f
commit
df12debd4c
3 changed files with 3 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ const posts = defineCollection({
|
||||||
pinned: z.boolean().optional(),
|
pinned: z.boolean().optional(),
|
||||||
category: z.string().optional(),
|
category: z.string().optional(),
|
||||||
draft: z.boolean().optional(),
|
draft: z.boolean().optional(),
|
||||||
|
slug: z.string(),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import Layout from '../../layouts/Layout.astro';
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const posts = await getCollection('posts', ({ data }) => data.draft !== true);
|
const posts = await getCollection('posts', ({ data }) => data.draft !== true);
|
||||||
return posts.map(post => ({
|
return posts.map(post => ({
|
||||||
params: { slug: post.id },
|
params: { slug: post.data.slug },
|
||||||
props: { post }
|
props: { post }
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ function formatDate(date: Date): string {
|
||||||
{sortedCategories.map(category => (
|
{sortedCategories.map(category => (
|
||||||
<details open>
|
<details open>
|
||||||
<summary>{category}</summary>
|
<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>
|
</details>
|
||||||
))}
|
))}
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue