Add RSS feed generation and TypeScript configuration for server routes
This commit is contained in:
37
server/routes/rss.xml.ts
Normal file
37
server/routes/rss.xml.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { Feed } from 'feed'
|
||||||
|
|
||||||
|
const basePath = 'https://nurriyad.com'
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event) => {
|
||||||
|
setHeader(event, 'content-type', 'text/xml')
|
||||||
|
const docs = await queryCollection(event, 'content').all()
|
||||||
|
const feed = new Feed({
|
||||||
|
title: "Riyad's personal blog site",
|
||||||
|
description: "Riyad's personal blog site",
|
||||||
|
id: basePath,
|
||||||
|
link: basePath,
|
||||||
|
language: 'en',
|
||||||
|
favicon: `${basePath}/favicon.ico`,
|
||||||
|
copyright: 'MIT',
|
||||||
|
author: {
|
||||||
|
name: 'Al Asad Nur Riyad',
|
||||||
|
email: 'asadnurriyad@gmail.com',
|
||||||
|
link: basePath,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// Add the feed items
|
||||||
|
docs.forEach((doc) => {
|
||||||
|
// console.log(doc)
|
||||||
|
feed.addItem({
|
||||||
|
title: doc.title || '',
|
||||||
|
id: basePath + doc.path,
|
||||||
|
link: basePath + doc.path,
|
||||||
|
description: doc.description,
|
||||||
|
content: doc.description,
|
||||||
|
date: new Date(doc.meta?.date as string),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return feed.rss2()
|
||||||
|
})
|
||||||
3
server/tsconfig.json
Normal file
3
server/tsconfig.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "../.nuxt/tsconfig.server.json"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user