refactor(site): remplace le blog par une collection projets

This commit is contained in:
Lucas committed 2026-10-21 13:57:25 +02:00
1 parent b98c5ed6c7
commit 72c1809485
23 files changed
+152 -700

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
---
import { getCollection, render } from 'astro:content';
import Projet from '../../layouts/Projet.astro';
export async function getStaticPaths() {
const projets = await getCollection('projets', ({ data }) => !data.brouillon);
return projets.map((projet) => ({ params: { slug: projet.id }, props: { projet } }));
}
const { projet } = Astro.props;
const { Content } = await render(projet);
---
<Projet {...projet.data}>
<Content />
</Projet>
+26
View File
@@ -0,0 +1,26 @@
---
import { getCollection } from 'astro:content';
import Base from '../../layouts/Base.astro';
const projets = (await getCollection('projets', ({ data }) => !data.brouillon)).sort(
(a, b) => b.data.date.valueOf() - a.data.date.valueOf(),
);
const sections = [
{ titre: 'Réalisations', items: projets.filter((p) => p.data.categorie === 'client') },
{ titre: 'Atelier', items: projets.filter((p) => p.data.categorie === 'atelier') },
];
---
<Base title="Projets">
<h1>Projets</h1>
{sections.map(({ titre, items }) => items.length > 0 && (
<section>
<h2>{titre}</h2>
<ul>
{items.map((p) => (
<li><a href={`/projets/${p.id}/`}>{p.data.titre}</a> : {p.data.resume}</li>
))}
</ul>
</section>
))}
</Base>