feat: 动态sitemap.xml

This commit is contained in:
2026-08-14 23:55:52 +08:00
parent d7bbb7b70b
commit e4c362030d
9 changed files with 99 additions and 61 deletions

21
src/pages/sitemap.xml.ts Normal file
View File

@@ -0,0 +1,21 @@
import type {APIRoute} from 'astro';
import {metadata} from "@/consts";
const site = metadata.site
export const GET: APIRoute = () => {
const xml = `<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>${site}/sitemap-pages.xml</loc>
</sitemap>
<sitemap>
<loc>${site}/sitemap-posts.xml</loc>
</sitemap>
</sitemapindex>`;
return new Response(xml, {
headers: {
'Content-Type': 'application/xml; charset=utf-8',
},
});
};