diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pages/rss.xml.ts | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts index fe7e9d2..9cfd560 100644 --- a/src/pages/rss.xml.ts +++ b/src/pages/rss.xml.ts @@ -1,22 +1,32 @@ import { SITE } from '@/consts' import rss from '@astrojs/rss' import type { APIContext } from 'astro' -import { getAllPosts } from '@/lib/data-utils' +import { getAllEvents, getAllPosts } from '@/lib/data-utils' export async function GET(context: APIContext) { try { const posts = await getAllPosts() - - return rss({ - title: SITE.title, - description: SITE.description, - site: context.site ?? SITE.href, - items: posts.map((post) => ({ + const events = await getAllEvents() + const items = [ + ...posts.map((post) => ({ title: post.data.title, description: post.data.description, pubDate: post.data.date, link: `/blog/${post.id}/`, })), + ...events.map((event) => ({ + title: event.data.title, + description: event.data.description, + pubDate: event.data.date, + link: `/events/${event.id}/`, + })) + ] + + return rss({ + title: SITE.title, + description: SITE.description, + site: context.site ?? SITE.href, + items: items }) } catch (error) { console.error('Error generating RSS feed:', error) |
