Skip to content

Commit

Permalink
auto sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaDemchenko committed Feb 12, 2024
1 parent aa6fd09 commit 71137d6
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 1 deletion.
10 changes: 9 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from "astro/config";

// https://astro.build/config
import sitemap from "@astrojs/sitemap";

export default defineConfig({
build: {
format: "preserve",
Expand All @@ -11,4 +12,11 @@ export default defineConfig({
},
syntaxHighlight: "shiki",
},
site: "http://novage.com.ua/",
integrations: [
sitemap({
priority: 0.8,
lastmod: new Date(),
}),
],
});
72 changes: 72 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/sitemap": "^3.0.5",
"astro": "^4.3.5",
"typescript": "^5.3.3"
},
Expand Down
17 changes: 17 additions & 0 deletions src/pages/robots.txt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { APIRoute } from "astro";
import astroConfig from "../../astro.config.mjs";

const robotsTxt = `
User-agent: *
Allow: /
Sitemap: ${new URL("sitemap-index.xml", astroConfig.site).href}
`.trim();

export const GET: APIRoute = () => {
return new Response(robotsTxt, {
headers: {
"Content-Type": "text/plain; charset=utf-8",
},
});
};

0 comments on commit 71137d6

Please sign in to comment.