Ajout du flux RSS pour le photo blog
Création de la route /rss.xml avec les 13 posts photo FR via @astrojs/rss.
This commit is contained in:
parent
23510f59b1
commit
c0cb3e08a0
1 changed files with 32 additions and 0 deletions
32
src/pages/rss.xml.ts
Normal file
32
src/pages/rss.xml.ts
Normal file
|
|
@ -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: "<language>fr</language>",
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue