Files
blog/app/feed.xml/route.ts
Gabriel Kaszewski c8536502bc
All checks were successful
Build and Deploy Blog / build-and-deploy-local (push) Successful in 1m13s
Add RSS feed functionality and icon to the blog
2025-09-15 08:27:57 +02:00

35 lines
935 B
TypeScript

import RSS from "rss";
import { getSortedPostsData } from "@/lib/posts";
export async function GET() {
const feed = new RSS({
title: "Gabriel Kaszewski's Blog",
description: "A personal blog by Gabriel Kaszewski about technology, programming, and game development.",
site_url: "https://blog.gabrielkaszewski.dev",
feed_url: "https://blog.gabrielkaszewski.dev/feed.xml",
language: "en",
pubDate: new Date(),
copyright: `© ${new Date().getFullYear()} Gabriel Kaszewski`,
});
const posts = getSortedPostsData();
posts.forEach((post) => {
feed.item({
title: post.title,
description: post.description,
url: `https://blog.gabrielkaszewski.dev/posts/${post.id}`,
guid: post.id,
date: post.date,
});
});
const xml = feed.xml({ indent: true });
return new Response(xml, {
headers: {
"Content-Type": "application/xml; charset=utf-8",
},
});
}