Add blog post detail page
This commit is contained in:
parent
be88d18dcc
commit
bb1b30fc2d
1 changed files with 25 additions and 0 deletions
25
apps/blog/src/pages/[slug].astro
Normal file
25
apps/blog/src/pages/[slug].astro
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
import { getCollection, render } from 'astro:content';
|
||||||
|
import '../styles/global.css';
|
||||||
|
|
||||||
|
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);
|
||||||
|
---
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head><title>{post.data.title}</title></head>
|
||||||
|
<body>
|
||||||
|
<article>
|
||||||
|
<h1>{post.data.title}</h1>
|
||||||
|
<Content />
|
||||||
|
</article>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue