Files
o2o-infinith-demo/supporters/src/pages/sitemap.xml.ts
T
Haewon KamandClaude Opus 5 bb68bdacad merge: feature/supporters-autobuild 진행분 (주변 안내 /stay, 워커 publish 색인 단계) 반영
머지 뒤에 브랜치가 5개 커밋 앞서 있었다. 주변 안내(/stay·/en/stay) 복원과
워커 publish 단계(IndexNow·검색 콘솔 소유 확인)가 거기 있었고, 먼저 올린 머지가
이 둘을 떨어뜨렸다. supporters/ 정본은 i18n 방식을 유지하고, 사이트맵과 site.json 은
양쪽 추가를 모두 살렸다. 템플릿은 supporters/ 에서 다시 내보낸다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 15:19:41 +09:00

29 lines
1.5 KiB
TypeScript

import type { APIRoute } from 'astro';
import { isPublishable } from '../lib';
import { getCollection } from 'astro:content';
import authors from '../data/authors.json';
export const GET: APIRoute = async ({ site }) => {
const base = site!.toString().replace(/\/$/, '');
const posts = (await getCollection('posts')).filter(isPublishable);
const today = new Date().toISOString().slice(0, 10);
const urls = [
{ loc: `${base}/`, lastmod: today },
{ loc: `${base}/posts`, lastmod: today },
{ loc: `${base}/clinic`, lastmod: today },
{ loc: `${base}/visit`, lastmod: today },
{ loc: `${base}/en`, lastmod: today },
{ loc: `${base}/stay`, lastmod: today },
{ loc: `${base}/en/stay`, lastmod: today },
{ loc: `${base}/plan`, lastmod: today },
{ loc: `${base}/en/plan`, lastmod: today },
{ loc: `${base}/newsroom`, lastmod: today },
{ loc: `${base}/videos`, lastmod: today },
{ loc: `${base}/about`, lastmod: today },
{ loc: `${base}/corrections`, lastmod: today },
...Object.keys(authors.supporters).map((id) => ({ loc: `${base}/authors/${id}`, lastmod: today })),
...posts.map((p) => ({ loc: `${base}/posts/${p.id}`, lastmod: p.data.dateModified })),
];
const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls.map((u) => ` <url><loc>${u.loc}</loc><lastmod>${u.lastmod}</lastmod></url>`).join('\n')}\n</urlset>\n`;
return new Response(xml, { headers: { 'Content-Type': 'application/xml; charset=utf-8' } });
};