Files
personalsite/app/sitemap.xml/route.ts
2026-04-03 16:20:51 +03:00

72 lines
2.6 KiB
TypeScript

import { NextResponse } from "next/server";
import { getAllPosts } from "@/lib/posts";
const SITE_URL = "https://denizbektas.com.tr";
const staticPages = [
{ url: "/", priority: "1.0", changefreq: "weekly" },
{ url: "/merhaba", priority: "0.8", changefreq: "monthly" },
{ url: "/hakkimda", priority: "0.8", changefreq: "monthly" },
{ url: "/su-anda", priority: "0.7", changefreq: "weekly" },
{ url: "/misyon", priority: "0.6", changefreq: "monthly" },
{ url: "/blog", priority: "0.9", changefreq: "weekly" },
{ url: "/infosec", priority: "0.9", changefreq: "weekly" },
{ url: "/notebook", priority: "0.8", changefreq: "weekly" },
{ url: "/seyir-defteri", priority: "0.7", changefreq: "weekly" },
{ url: "/faydali-linkler", priority: "0.7", changefreq: "monthly" },
{ url: "/roadmap", priority: "0.8", changefreq: "monthly" },
{ url: "/takim-cantam", priority: "0.6", changefreq: "monthly" },
{ url: "/hobilerim", priority: "0.5", changefreq: "monthly" },
{ url: "/fikirlerim", priority: "0.7", changefreq: "monthly" },
{ url: "/projeler", priority: "0.8", changefreq: "monthly" },
{ url: "/podcast", priority: "0.7", changefreq: "weekly" },
{ url: "/iletisim", priority: "0.6", changefreq: "monthly" },
{ url: "/ozgecmis", priority: "0.7", changefreq: "monthly" },
{ url: "/aktivite", priority: "0.6", changefreq: "daily" },
{ url: "/rss-beslemeleri", priority: "0.5", changefreq: "monthly" },
{ url: "/statboard", priority: "0.5", changefreq: "monthly" },
{ url: "/altyapi", priority: "0.5", changefreq: "monthly" },
{ url: "/tesekkurler", priority: "0.4", changefreq: "yearly" },
{ url: "/gizlilik", priority: "0.3", changefreq: "yearly" },
{ url: "/kullanim-kosullari", priority: "0.3", changefreq: "yearly" },
];
export async function GET() {
const posts = getAllPosts();
const now = new Date().toISOString().split("T")[0];
const staticUrls = staticPages
.map(
(p) => `
<url>
<loc>${SITE_URL}${p.url}</loc>
<lastmod>${now}</lastmod>
<changefreq>${p.changefreq}</changefreq>
<priority>${p.priority}</priority>
</url>`
)
.join("");
const postUrls = posts
.map(
(p) => `
<url>
<loc>${SITE_URL}/${p.category}/${p.slug}</loc>
<lastmod>${p.date}</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>`
)
.join("");
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${staticUrls}
${postUrls}
</urlset>`;
return new NextResponse(xml, {
headers: { "Content-Type": "application/xml; charset=utf-8", "Cache-Control": "public, max-age=86400" },
});
}