17 lines
593 B
Plaintext
17 lines
593 B
Plaintext
---
|
|
import { getCollection } from 'astro:content';
|
|
import BlogPostLayout from '../../layouts/BlogPostLayout.astro'; // Using BlogPostLayout
|
|
|
|
// 1. Generate a path for every blog post
|
|
export async function getStaticPaths() {
|
|
const postEntries = await getCollection('posts');
|
|
return postEntries.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();
|
|
---
|
|
<BlogPostLayout frontmatter={entry.data}> <Content /> </BlogPostLayout> |