sync
This commit is contained in:
17
src/pages/[lang]/blog/[...slug].astro
Normal file
17
src/pages/[lang]/blog/[...slug].astro
Normal 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 />
|
Reference in New Issue
Block a user