diff options
Diffstat (limited to 'src/pages/posts/feed.xml.ts')
| -rw-r--r-- | src/pages/posts/feed.xml.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/pages/posts/feed.xml.ts b/src/pages/posts/feed.xml.ts new file mode 100644 index 0000000..43b9b84 --- /dev/null +++ b/src/pages/posts/feed.xml.ts @@ -0,0 +1,21 @@ +import rss from '@astrojs/rss'; +import { getCollection } from 'astro:content'; +import { marked } from 'marked'; +import type { APIContext } from 'astro'; + +export async function GET(context: APIContext) { + const posts = await getCollection('posts'); + posts.sort((a, b) => b.data.date.localeCompare(a.data.date)); + + return rss({ + title: "Matthew Kosarek's Blog", + description: 'Updates and thoughts from Matthew Kosarek', + site: context.site ?? 'https://matthewkosarek.xyz', + items: posts.map(post => ({ + title: post.data.title, + pubDate: new Date(post.data.date), + link: `/posts/${post.slug}/`, + content: marked(post.body) as string, + })), + }); +} |
