Skip to content

Commit

Permalink
feat: add sitemap and robot txt generation
Browse files Browse the repository at this point in the history
  • Loading branch information
sh3pik authored and p0deje committed Feb 1, 2025
1 parent da38b55 commit e15af33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check
import { defineConfig, sharpImageService } from "astro/config";
import starlight from "@astrojs/starlight";
import sitemap from "@astrojs/sitemap";

import tailwind from "@astrojs/tailwind";

Expand Down Expand Up @@ -95,5 +96,6 @@ export default defineConfig({
customCss: ["./src/tailwind.css"],
}),
tailwind({ applyBaseStyles: false }),
sitemap({}),
],
});
13 changes: 13 additions & 0 deletions src/pages/robots.txt.ts
Original file line number Diff line number Diff line change
@@ -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));
};

0 comments on commit e15af33

Please sign in to comment.