Yufan Sheng
901cd8219c
* 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.
30 lines
837 B
TypeScript
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',
|
|
},
|
|
});
|
|
};
|