From c0cb3e08a0928abb4f3d814bbd33bce0d65e8b49 Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Sat, 21 Feb 2026 14:40:33 +0100 Subject: [PATCH] Ajout du flux RSS pour le photo blog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Création de la route /rss.xml avec les 13 posts photo FR via @astrojs/rss. --- src/pages/rss.xml.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/pages/rss.xml.ts diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts new file mode 100644 index 0000000..71a2ed3 --- /dev/null +++ b/src/pages/rss.xml.ts @@ -0,0 +1,32 @@ +import rss from "@astrojs/rss"; +import type { APIContext } from "astro"; +import { getCollection } from "astro:content"; +import { getPostBaseSlug } from "../utils/i18n"; + +export async function GET(context: APIContext) { + const photoBlogPosts = await getCollection("photoBlogPosts"); + const frPosts = photoBlogPosts + .filter((post) => (post.data.lang ?? "fr") === "fr") + .sort( + (a, b) => + new Date(b.data.date).getTime() - new Date(a.data.date).getTime(), + ); + + return rss({ + title: "Jalil Arfaoui — Photo Blog", + description: + "Blog photo de Jalil Arfaoui. Reportages, séries et histoires en images.", + site: context.site!.toString(), + items: frPosts.map((post) => { + const slug = getPostBaseSlug(post.id); + const year = post.data.date.getFullYear(); + return { + title: post.data.title, + description: post.data.description, + pubDate: new Date(post.data.date), + link: `/photo/blog/${year}/${slug}/`, + }; + }), + customData: "fr", + }); +}