Skip to content

Commit

Permalink
Add sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
derekmbrown committed Dec 7, 2024
1 parent 54f3584 commit af3d791
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
6 changes: 4 additions & 2 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { defineConfig } from 'astro/config'
import tailwind from "@astrojs/tailwind"
import { remarkHeadingId } from 'remark-custom-heading-id'
import remarkCodeTitles from "remark-code-titles";
import remarkCodeTitles from 'remark-code-titles'
import sitemap from '@astrojs/sitemap'

// https://astro.build/config
export default defineConfig({
integrations: [ tailwind() ],
integrations: [ tailwind(), sitemap()],
site: 'https://derekbrown.io',
markdown: {
syntaxHighlight: 'shiki',
Expand All @@ -15,4 +16,5 @@ export default defineConfig({
wrap: true
},
},
trailingSlash: 'never'
});
55 changes: 55 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 @@ -11,6 +11,7 @@
},
"dependencies": {
"@astrojs/rss": "^4.0.5",
"@astrojs/sitemap": "^3.2.1",
"@astrojs/tailwind": "^5.0.2",
"@fontsource-variable/inter": "^5.0.16",
"@fontsource-variable/manrope": "^5.0.15",
Expand Down
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 af3d791

Please sign in to comment.