25 lines
687 B
Plaintext
25 lines
687 B
Plaintext
---
|
|
import { getCollection } from 'astro:content';
|
|
import Layout from '../../layouts/Layout.astro';
|
|
|
|
// 1. Génère une page pour chaque entrée de la collection 'journal'
|
|
export async function getStaticPaths() {
|
|
const journalEntries = await getCollection('journal');
|
|
return journalEntries.map(entry => ({
|
|
params: { slug: entry.slug },
|
|
props: { entry },
|
|
}));
|
|
}
|
|
|
|
// 2. Récupère les props pour la page actuelle
|
|
const { entry } = Astro.props;
|
|
const { Content } = await entry.render();
|
|
---
|
|
|
|
<Layout title={entry.data.title}>
|
|
<h1>{entry.data.title}</h1>
|
|
<p>Par {entry.data.author}, le {entry.data.publishDate.toLocaleDateString('fr-FR')}</p>
|
|
<hr>
|
|
<Content />
|
|
</Layout>
|