mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
chore: update robots.txt implementation
This commit is contained in:
+7
-11
@@ -1,17 +1,13 @@
|
|||||||
import type { APIRoute } from "astro";
|
import type { APIRoute } from "astro";
|
||||||
import { SITE } from "@config";
|
|
||||||
|
|
||||||
const robots = `
|
|
||||||
User-agent: Googlebot
|
|
||||||
Disallow: /nogooglebot/
|
|
||||||
|
|
||||||
|
const getRobotsTxt = (sitemapURL: URL) => `
|
||||||
User-agent: *
|
User-agent: *
|
||||||
Allow: /
|
Allow: /
|
||||||
|
|
||||||
Sitemap: ${new URL("sitemap-index.xml", SITE.website).href}
|
Sitemap: ${sitemapURL.href}
|
||||||
`.trim();
|
`;
|
||||||
|
|
||||||
export const GET: APIRoute = () =>
|
export const GET: APIRoute = ({ site }) => {
|
||||||
new Response(robots, {
|
const sitemapURL = new URL("sitemap-index.xml", site);
|
||||||
headers: { "Content-Type": "text/plain" },
|
return new Response(getRobotsTxt(sitemapURL));
|
||||||
});
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user