Add RSS mechnaisms

This commit is contained in:
2023-11-27 19:30:58 -06:00
parent dec63c64d5
commit 008f1bf960
3 changed files with 46 additions and 0 deletions

24
src/pages/feed.xml.ts Normal file
View File

@@ -0,0 +1,24 @@
// src/pages/rss.xml.js
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
export async function GET(context) {
const posts = await getCollection('blog');
return rss({
title: 'Undefined Behaviors',
description: 'A amateur\'s blog discussing programming, technology, and other things.',
// Pull in your project "site" from the endpoint context
// https://docs.astro.build/en/reference/api-reference/#contextsite
site: context.site,
items: posts.map((post) => ({
title: post.data.title,
description: post.data.description,
pubDate: post.data.pubDate,
categories: post.data.tags,
// Generate a `url` from each post `slug`
// This assumes all blog posts are rendered as `/blog/[slug]` routes
// https://docs.astro.build/en/guides/content-collections/#generating-pages-from-content-collections
link: `/posts/${post.slug}/`,
})),
});
}