feat: add md slug page for individual posts
This commit is contained in:
parent
b71a780ef8
commit
6ef5b3a413
1 changed files with 22 additions and 0 deletions
22
apps/blog/src/pages/md/[slug].astro
Normal file
22
apps/blog/src/pages/md/[slug].astro
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
import { getCollection, render } from 'astro:content';
|
||||
import Layout from '../../layouts/Layout.astro';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getCollection('posts');
|
||||
return posts.map(post => ({
|
||||
params: { slug: post.id },
|
||||
props: { post }
|
||||
}));
|
||||
}
|
||||
|
||||
const { post } = Astro.props;
|
||||
const { Content } = await render(post);
|
||||
---
|
||||
<Layout title={`${post.data.title} - lewis m.w.`}>
|
||||
|
||||
<article>
|
||||
<h1>{post.data.title}</h1>
|
||||
<Content />
|
||||
</article>
|
||||
</Layout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue