Add sitemap and robots

This commit is contained in:
2025-08-08 19:06:40 +09:30
parent 73cb49ae0c
commit 7b42e5045b
5 changed files with 83 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ const headDescription: string = description || site.description;
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="apple-touch-icon" href="/favicon.png" />
<link rel="sitemap" href="/sitemap-index.xml" />
<SEO title={headTitle} description={headDescription} {image} />
<ThemeManager defaultTheme="auto" />

13
src/pages/robots.txt.ts Normal file
View File

@@ -0,0 +1,13 @@
import type { APIRoute } from "astro";
const getRobotsTxt = (sitemapURL: URL) => `\
User-agent: *
Allow: /
Sitemap: ${sitemapURL.href}
`;
export const GET: APIRoute = ({ site }) => {
const sitemapURL = new URL("sitemap-index.xml", site);
return new Response(getRobotsTxt(sitemapURL));
};