deniz bektaş
This commit is contained in:
38
app/api/rss/blog/route.ts
Normal file
38
app/api/rss/blog/route.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getPosts } from "@/lib/posts";
|
||||
|
||||
const SITE_URL = "https://denizbektas.com.tr";
|
||||
|
||||
export async function GET() {
|
||||
const posts = getPosts("blog");
|
||||
|
||||
const items = posts
|
||||
.map(
|
||||
(post) => `
|
||||
<item>
|
||||
<title><![CDATA[${post.title}]]></title>
|
||||
<link>${SITE_URL}/blog/${post.slug}</link>
|
||||
<guid>${SITE_URL}/blog/${post.slug}</guid>
|
||||
<pubDate>${new Date(post.date).toUTCString()}</pubDate>
|
||||
<description><![CDATA[${post.excerpt}]]></description>
|
||||
</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ş — Kişisel Blog</title>
|
||||
<link>${SITE_URL}/blog</link>
|
||||
<description>Kişisel blog yazıları</description>
|
||||
<language>tr</language>
|
||||
<atom:link href="${SITE_URL}/api/rss/blog" 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" },
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user