import { SITE, authors, categories, sortedPosts, tags } from "../lib/blog-data.js"; import { getProjects } from "../lib/projects.js"; const BASE_URL = SITE.url || ""; export async function GET() { const posts = await sortedPosts(); const projects = await getProjects(); const entries = [ { path: "/", changefreq: "weekly", priority: "1.0" }, { path: "/about", changefreq: "monthly", priority: "0.6" }, { path: "/services", changefreq: "monthly", priority: "0.7" }, { path: "/services/website-design", changefreq: "monthly", priority: "0.6" }, { path: "/projects", changefreq: "weekly", priority: "0.8" }, { path: "/resume", changefreq: "monthly", priority: "0.6" }, { path: "/contact", changefreq: "monthly", priority: "0.5" }, { path: "/faq", changefreq: "monthly", priority: "0.4" }, { path: "/changelog", changefreq: "weekly", priority: "0.3" }, { path: "/blog", changefreq: "daily", priority: "0.9" }, ...projects.map((project) => ({ path: `/projects/${project.slug}`, changefreq: "monthly", priority: "0.7", })), ...posts.map((post) => ({ path: `/blog/${post.slug}`, lastmod: post.updated || post.date, changefreq: "monthly", priority: "0.8", })), ...categories.map((category) => ({ path: `/categories/${category.slug}`, changefreq: "weekly", priority: "0.6", })), ...tags.map((tag) => ({ path: `/tags/${tag.slug}`, changefreq: "weekly", priority: "0.4", })), ...authors.map((author) => ({ path: `/authors/${author.slug}`, changefreq: "monthly", priority: "0.5", })), ]; const urls = entries.map((entry) => [ " ", ` ${BASE_URL}${entry.path}`, entry.lastmod ? ` ${entry.lastmod}` : null, entry.changefreq ? ` ${entry.changefreq}` : null, entry.priority ? ` ${entry.priority}` : null, " ", ] .filter(Boolean) .join("\n"), ); const xml = [ '', '', ...urls, "", ].join("\n"); return new Response(xml, { headers: { "Content-Type": "application/xml", "Cache-Control": "public, max-age=3600", }, }); }