This commit is contained in:
Zoe
2023-02-10 23:05:26 -06:00
parent 0018011cd3
commit fb357cb768
5 changed files with 12 additions and 7 deletions

23
server/routes/rss.xml.ts Normal file
View File

@@ -0,0 +1,23 @@
import { serverQueryContent } from '#content/server'
import { streamToPromise } from 'sitemap'
import RSS from 'rss'
export default defineEventHandler(async (event) => {
// Fetch all documents
const docs = await serverQueryContent(event).where({ _draft: false }).find()
const feed = new RSS({
title: 'Juls07',
description: 'Juls07\'s blogs',
link: 'https://juls07.dev/blogs'
})
for (const doc of docs) {
feed.item({
title: doc.title,
description: doc.description,
image_url: doc.image.src,
})
}
return feed.xml({ indent: true })
})