This commit is contained in:
Blboun3
2024-05-29 07:19:55 +02:00
parent 986ea7ef3f
commit fdc43aa699
4 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,17 @@
---
import { getCollection } from 'astro:content';
// 1. Generate a new path for every collection entry
export async function getStaticPaths() {
const blogEntries = await getCollection('blog');
console.log(blogEntries)
return blogEntries.map(entry => ({
params: { slug: entry.slug }, props: { entry },
}));
}
// 2. For your template, you can get the entry directly from the prop
const { entry } = Astro.props;
const { Content } = await entry.render();
---
<h1>{entry.data.title}</h1>
<Content />