diff --git a/src/content/config.ts b/src/content/config.ts index 1a89afa..d18de4c 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -1,16 +1,9 @@ import { defineCollection, z } from 'astro:content'; +import { rssSchema } from '@astrojs/rss'; const blog = defineCollection({ // Type-check frontmatter using a schema - schema: z.object({ - title: z.string(), - description: z.string(), - // Transform string to Date object - pubDate: z - .string() - .or(z.date()) - .transform((val) => new Date(val)) - }), + schema: rssSchema }); export const collections = { blog }; diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index 7d054b9..811cc42 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -1,16 +1,18 @@ import rss from '@astrojs/rss'; import { getCollection } from 'astro:content'; -import { SITE_TITLE, SITE_DESCRIPTION } from '../consts'; -export async function get(context) { - const posts = await getCollection('blog'); - return rss({ - title: SITE_TITLE, - description: SITE_DESCRIPTION, - site: context.site, - items: posts.map((post) => ({ - ...post.data, - link: `/blog/${post.slug}/`, - })), - }); -} +export async function GET(context) { + const blog = await getCollection('blog'); + return rss({ + title: 'Sindre Kjelsrud', + description: 'Recent content on Sindre Kjelsrud`s blog', + site: context.site, + items: blog.map((post) => ({ + title: post.data.title, + pubDate: post.data.pubDate, + description: post.data.description, + customData: post.data.customData, + link: `/blog/${post.slug}/`, + })), + }); +} \ No newline at end of file