Skip to content

Commit

Permalink
chore: Update astro.config.mjs with sitemap integration
Browse files Browse the repository at this point in the history
  • Loading branch information
RND332 committed Jun 14, 2024
1 parent f9a5dee commit f21da6c
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
6 changes: 4 additions & 2 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { defineConfig, passthroughImageService } from 'astro/config';
import tailwind from "@astrojs/tailwind";
import mdx from '@astrojs/mdx';

import sitemap from "@astrojs/sitemap";

// https://astro.build/config
export default defineConfig({
integrations: [tailwind(), mdx()],
integrations: [tailwind(), mdx(), sitemap()],
site: 'https://rnd332.com',
build: {
inlineStylesheets: 'always',
inlineStylesheets: 'always'
},
image: {
service: passthroughImageService()
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@astrojs/check": "^0.7.0",
"@astrojs/mdx": "^3.1.0",
"@astrojs/react": "^3.4.0",
"@astrojs/sitemap": "^3.1.5",
"@astrojs/tailwind": "^5.1.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
Expand Down
46 changes: 46 additions & 0 deletions pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const pages: Array<Page> = [
href="https://fonts.googleapis.com/css2?family=Inconsolata:[email protected]&display=swap"
rel="preconnect"
/>
<link rel="sitemap" type="application/xml" href="/sitemap-0.xml" />
<meta name="generator" content={Astro.generator} />
<title>RND</title>
<ViewTransitions />
Expand Down
16 changes: 16 additions & 0 deletions src/pages/robots.txt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { APIRoute } from 'astro';

const robotsTxt = `
User-agent: *
Allow: /
Sitemap: ${new URL('sitemap-index.xml', import.meta.env.SITE).href}
`.trim();

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

0 comments on commit f21da6c

Please sign in to comment.