Files
personalsite/app/api/rss/all/route.ts
2026-04-03 16:20:51 +03:00

43 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { NextResponse } from "next/server";
import { getAllPosts } from "@/lib/posts";
const SITE_URL = "https://denizbektas.com.tr";
export async function GET() {
const posts = getAllPosts();
const items = posts
.map(
(post) => `
<item>
<title><![CDATA[${post.title}]]></title>
<link>${SITE_URL}/${post.category}/${post.slug}</link>
<guid>${SITE_URL}/${post.category}/${post.slug}</guid>
<pubDate>${new Date(post.date).toUTCString()}</pubDate>
<description><![CDATA[${post.excerpt}]]></description>
<category>${post.category}</category>
</item>`
)
.join("\n");
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Deniz Bektaş — Tüm İçerikler</title>
<link>${SITE_URL}</link>
<description>Siber güvenlik, red team ve kişisel yazılar</description>
<language>tr</language>
<atom:link href="${SITE_URL}/api/rss/all" rel="self" type="application/rss+xml"/>
<lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
${items}
</channel>
</rss>`;
return new NextResponse(xml, {
headers: {
"Content-Type": "application/xml; charset=utf-8",
"Cache-Control": "public, max-age=3600",
},
});
}