Skip to content

Commit

Permalink
minor-feat: add generator sitemap.xml & robot.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanFama592 committed Feb 9, 2024
1 parent 55216d7 commit 5d6a493
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
URL="base url. example: 'https://example.com' "
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist/

# generated types
.astro/
.vercel/

# dependencies
node_modules/
Expand Down
4 changes: 3 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { defineConfig } from 'astro/config';
import react from '@astrojs/react';
import tailwindcss from '@astrojs/tailwind';
import sitemap from '@astrojs/sitemap';
import vercel from "@astrojs/vercel/static"

// https://astro.build/config
export default defineConfig({
server: {
port: 8081
},
site: process.env.URL,
adapter: vercel({
webAnalytics: {
enabled: true,
Expand All @@ -21,5 +23,5 @@ export default defineConfig({
}
}
},
integrations: [react(), tailwindcss()]
integrations: [sitemap(), react(), tailwindcss()]
});
Binary file modified bun.lockb
Binary file not shown.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "tic-tac-toe-world",
"version": "1.2.6",
"version": "1.2.7",
"scripts": {
"dev": "astro dev --host",
"start:build": "astro check && astro build && astro preview --host",
Expand All @@ -22,8 +22,9 @@
"tailwindcss": "^3.4.1"
},
"devDependencies": {
"@types/react": "^18.2.48",
"@astrojs/check": "^0.4.1",
"@astrojs/sitemap": "^3.0.5",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"autoprefixer": "^10.4.17",
"cssnano": "^6.0.3",
Expand Down
1 change: 1 addition & 0 deletions src/layouts/LayoutHTML.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const { title, description = "" }: Props = Astro.props;
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />
<link rel="sitemap" href="/sitemap-index.xml" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<slot name="head" />
Expand Down
16 changes: 16 additions & 0 deletions src/pages/robot.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', process.env.URL).href}
`.trim();

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

0 comments on commit 5d6a493

Please sign in to comment.