Skip to content

Commit

Permalink
feat: add rss feed
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlatz committed Jan 13, 2025
1 parent ab78069 commit d9a93b9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/pages/rss.xml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import rss from '@astrojs/rss';
import config from '@/config/config.json';
import {getCollection} from 'astro:content';
import {sortByDate} from "../lib/utils/sortFunctions";

// noinspection JSUnusedGlobalSymbols
export async function GET(context: { site: any; }) {
const posts = await getCollection('posts');
const sortedPosts = sortByDate(posts);
return rss({
title: config.site.title,
description: config.metadata.meta_description,
site: context.site,
items: sortedPosts.map((post) => ({
title: post.data.title,
pubDate: post.data.date,
description: post.data.description,
link: `/posts/${post.slug}`,
})),
customData: `<language>fr-fr</language>`,
});
}

0 comments on commit d9a93b9

Please sign in to comment.