mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-13 12:00:01 -04:00
More SEO garbage
This commit is contained in:
parent
6c0cbf2737
commit
6de99225c4
1 changed files with 15 additions and 3 deletions
|
@ -1,6 +1,10 @@
|
||||||
import type { APIRoute } from "astro";
|
import type { APIRoute } from "astro";
|
||||||
import { SEO } from "astro:env/client";
|
import { SEO } from "astro:env/client";
|
||||||
const SEOConfig = JSON.stringify(SEO);
|
interface config {
|
||||||
|
enabled: boolean;
|
||||||
|
domain: string;
|
||||||
|
}
|
||||||
|
const SEOConfig: config = JSON.parse(SEO);
|
||||||
|
|
||||||
const genRobotsTXT = (sitemap: URL) => `
|
const genRobotsTXT = (sitemap: URL) => `
|
||||||
User-Agent: *
|
User-Agent: *
|
||||||
|
@ -10,8 +14,16 @@ Disallow: /uv
|
||||||
SiteMap: ${sitemap.href}
|
SiteMap: ${sitemap.href}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const otherDomainTXT = `
|
||||||
|
User-Agent: *
|
||||||
|
Disallow: /*
|
||||||
|
`
|
||||||
|
|
||||||
export const GET: APIRoute = ({ site, request }) => {
|
export const GET: APIRoute = ({ site, request }) => {
|
||||||
const url = new URL('sitemap-index.xml', site);
|
const url = new URL('sitemap-index.xml', site);
|
||||||
console.log(new URL(request.url).host);
|
const host = new URL(request.url).host;
|
||||||
return new Response(genRobotsTXT(url));
|
if (SEOConfig.enabled && host === SEOConfig.domain) {
|
||||||
|
return new Response(genRobotsTXT(url));
|
||||||
|
}
|
||||||
|
return new Response(otherDomainTXT);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue