chore: update robots.txt implementation

This commit is contained in:
satnaing
2025-02-25 20:36:22 +07:00
committed by Sat Naing
parent 172e14b5f4
commit f71fdc1398
+7 -11
View File
@@ -1,17 +1,13 @@
import type { APIRoute } from "astro";
import { SITE } from "@config";
const robots = `
User-agent: Googlebot
Disallow: /nogooglebot/
const getRobotsTxt = (sitemapURL: URL) => `
User-agent: *
Allow: /
Sitemap: ${new URL("sitemap-index.xml", SITE.website).href}
`.trim();
Sitemap: ${sitemapURL.href}
`;
export const GET: APIRoute = () =>
new Response(robots, {
headers: { "Content-Type": "text/plain" },
});
export const GET: APIRoute = ({ site }) => {
const sitemapURL = new URL("sitemap-index.xml", site);
return new Response(getRobotsTxt(sitemapURL));
};