sp/src/pages/robots.txt.ts

22 lines
387 B
TypeScript

import type { APIRoute } from 'astro';
export const GET: APIRoute = async ({ site }) => {
if (!site) {
return new Response('Site configuration error', { status: 500 });
}
const siteUrl = site.toString();
return new Response(
`User-agent: *
Allow: /
Sitemap: ${siteUrl}/sitemap.xml`,
{
headers: {
'Content-Type': 'text/plain',
},
}
);
};