feat: update robots.txt
This commit is contained in:
@@ -1,31 +1,14 @@
|
|||||||
// https://docs.astro.build/en/guides/integrations-guide/sitemap/#usage
|
// https://docs.astro.build/en/guides/integrations-guide/sitemap/#usage
|
||||||
import type { APIRoute } from 'astro';
|
import type { APIRoute } from 'astro';
|
||||||
|
|
||||||
const robotsTxt = `
|
const getRobotsTxt = (sitemapURL: URL) => `\
|
||||||
User-agent: Googlebot
|
|
||||||
Disallow:
|
|
||||||
Allow: /
|
|
||||||
Crawl-delay: 10
|
|
||||||
|
|
||||||
User-agent: Yandex
|
|
||||||
Disallow:
|
|
||||||
Allow: /
|
|
||||||
Crawl-delay: 2
|
|
||||||
|
|
||||||
User-agent: archive.org_bot
|
|
||||||
Disallow:
|
|
||||||
Allow: /
|
|
||||||
Crawl-delay: 2
|
|
||||||
|
|
||||||
User-agent: *
|
User-agent: *
|
||||||
Allow: /
|
Allow: /
|
||||||
|
|
||||||
Sitemap: ${new URL('sitemap-index.xml', import.meta.env.SITE).href}`.trim();
|
Sitemap: ${sitemapURL.href}
|
||||||
|
`;
|
||||||
|
|
||||||
export const GET: APIRoute = () => {
|
export const GET: APIRoute = ({ site }) => {
|
||||||
return new Response(robotsTxt, {
|
const sitemapURL = new URL('sitemap-index.xml', site);
|
||||||
headers: {
|
return new Response(getRobotsTxt(sitemapURL));
|
||||||
'Content-Type': 'text/plain; charset=utf-8',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user