Files
o2o-infinith-demo/templates/supporters-astro/src/pages/sitemap.xml.ts
T
Haewon KamandClaude Opus 5 82aa56fa40 chore(supporters): 통합 뒤 템플릿 재생성 (주변 안내 포함, 영어 홈 안전 기본값)
정본 supporters/ 와 템플릿의 페이지 집합이 같아졌다.
/stay·/en/stay·/en·/plan·/en/plan 이 양쪽에 모두 있다.

검증
- 뷰 34페이지, 게이트 41/41, check.mjs 오류 0건.
- 빈 데이터 템플릿 16페이지, 영어 홈에 병원 고유 사실 0건, 문장 성립.
- 내보내기 종료코드 0, tsc 0 에러.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 15:21:31 +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' } });
};