yufan.me/src/pages/sitemap.xml.ts
Yufan Sheng 901cd8219c
feat: add upyun support. move images to upyun on build. (#45)
* style: better reply button.

* feat: add astro badge.

* chore: drop useless styles.

* feat: use new options.ts for global configuration.

* fix: the invalid import.meta.env.PROD in astro build.

* feat: move og to new assert prefix.

* chore: add better og description.

* chore: make sure all the images link could be correctly replaced.

* feat: add upyun uploader.
2024-06-19 03:34:36 +08:00

30 lines
837 B
TypeScript

import { pages, posts } from '@/helpers/schema';
import { urlJoin } from '@/helpers/tools';
export const prerender = true;
export const GET = async () => {
const result = `
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>${import.meta.env.SITE}/</loc></url>
${posts
.map((post) => {
return `<url><loc>${urlJoin(import.meta.env.SITE, post.permalink)}</loc><lastmod>${post.date.toISOString()}</lastmod></url>`;
})
.join('\n')}
${pages
.map((page) => {
return `<url><loc>${urlJoin(import.meta.env.SITE, page.permalink)}</loc><lastmod>${page.date.toISOString()}</lastmod></url>`;
})
.join('\n')}
</urlset>
`.trim();
return new Response(result, {
headers: {
'Content-Type': 'application/xml',
},
});
};