/**
* 케이스 8-b: sitemap.xml
*
* server/routes/ 사용 사례 — /api 접두사 없이 /sitemap.xml URL로 직접 제공
*
* URL: GET /sitemap.xml
*/
export default defineEventHandler((event) => {
// XML Content-Type 지정
setHeader(event, "Content-Type", "application/xml");
const baseUrl = "https://example.com";
// 실제 프로젝트에서는 DB나 파일 시스템에서 동적으로 URL 목록을 가져옴
const pages = [
{ url: "/", lastmod: "2026-04-01", changefreq: "daily", priority: "1.0" },
{ url: "/about", lastmod: "2026-03-15", changefreq: "monthly", priority: "0.8" },
{ url: "/blog", lastmod: "2026-04-07", changefreq: "weekly", priority: "0.9" },
{ url: "/blog/nuxt4-release", lastmod: "2026-04-01", changefreq: "yearly", priority: "0.7" },
{ url: "/contact", lastmod: "2026-01-01", changefreq: "yearly", priority: "0.5" },
];
const urls = pages
.map(
(page) => `
${baseUrl}${page.url}
${page.lastmod}
${page.changefreq}
${page.priority}
`
)
.join("");
return `
${urls}
`;
});