1
0
mirror of https://github.com/tabler/tabler.git synced 2026-08-07 20:02:23 +04:00
Files
tabler/preview/pages/robots.txt.ts
T
2026-07-28 00:09:02 +02:00

24 lines
657 B
TypeScript

import type { APIRoute } from 'astro';
import { site } from '@shared/lib/site';
export const prerender = true;
// Port of preview/pages/robots.liquid: the sitemap URL is absolute outside
// development, and crawling is allowed only in the preview environment.
export const GET: APIRoute = () => {
const environment = process.env.NODE_ENV || 'production';
const sitemapBase = environment !== 'development' ? site.previewUrl : '';
const body = `Sitemap: ${sitemapBase}/sitemap.xml
User-agent: *
Disallow:${environment === 'preview' ? '' : ' /'}
`;
return new Response(body, {
headers: {
'Content-Type': 'text/plain; charset=utf-8',
},
});
};