dashersupply/src/pages/robots.txt.ts

23 lines
526 B
TypeScript

import type { APIRoute } from 'astro';
const shouldPermitRobots = import.meta.env.MODE !== 'development';
const permissiveRobotsTxt = `
User-agent: *
Allow: /
Sitemap: ${new URL('sitemap-index.xml', import.meta.env.SITE).href}
`.trimStart();
const restrictiveRobotsTxt = `
User-agent: *
Disallow: /
`.trimStart();
export const GET: APIRoute = () => {
return new Response(shouldPermitRobots ? permissiveRobotsTxt : restrictiveRobotsTxt, {
headers: {
'Content-Type': 'text/plain; charset=utf-8',
},
});
};