-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathfeed.xml.ts
More file actions
26 lines (22 loc) · 684 Bytes
/
feed.xml.ts
File metadata and controls
26 lines (22 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import rss from '@astrojs/rss'
import type { AstroConfig } from 'astro'
import { metadata } from '@/config'
import { getAllPosts, getFeedContent } from '@/features/posts/lib'
const { siteTitle, siteDescription } = metadata
export async function GET(context: AstroConfig) {
const allPostsSorted = await getAllPosts()
const items = await Promise.all(
allPostsSorted.map(async (post) => ({
title: post.data.title,
pubDate: post.data.date,
link: `${context.site}${post.data.slug}`,
content: await getFeedContent(post)
}))
)
return rss({
title: siteTitle,
description: siteDescription,
site: context.site as string,
items
})
}