mirror of
https://github.com/tabler/tabler.git
synced 2026-08-07 20:02:23 +04:00
d8956a06d6
Co-authored-by: Bartek <xbartoszdobija@gmail.com>
24 lines
657 B
TypeScript
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',
|
|
},
|
|
});
|
|
};
|