33 lines
716 B
TypeScript
33 lines
716 B
TypeScript
import type {APIRoute} from 'astro';
|
|
import {siteConfig} from "@/consts";
|
|
|
|
const site = siteConfig.site
|
|
|
|
const staticUrls = [
|
|
'',
|
|
'/archive'
|
|
];
|
|
|
|
export const GET: APIRoute = async () => {
|
|
const urls = staticUrls
|
|
.filter((url, index, array) => {
|
|
return array.indexOf(url) === index;
|
|
});
|
|
|
|
const xml = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
${urls.map((url) => `<url>
|
|
<loc>${site}${url}</loc>
|
|
</url>`
|
|
)
|
|
.join('\n')}
|
|
</urlset>`;
|
|
|
|
return new Response(xml, {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'application/xml; charset=utf-8',
|
|
'Cache-Control': 'public, max-age=3600, s-maxage=3600',
|
|
},
|
|
});
|
|
};
|