Skip to content

Commit

Permalink
Merge pull request #188 from oystersjp/feature/v2-sitemap
Browse files Browse the repository at this point in the history
[oysters.dev v2] sitemapの追加
  • Loading branch information
mii288 authored Aug 18, 2024
2 parents b26adee + d246087 commit 7f606fd
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 2 deletions.
9 changes: 8 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { defineConfig } from 'astro/config'
import tailwind from '@astrojs/tailwind'

import sitemap from '@astrojs/sitemap'

// https://astro.build/config
export default defineConfig({
site: 'https://oysters.dev',
integrations: [tailwind()]
integrations: [
tailwind(),
sitemap({
customPages: ['https://oysters.dev/podcast']
})
]
})
73 changes: 73 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 @@ -20,6 +20,7 @@
},
"dependencies": {
"@astrojs/check": "^0.9.2",
"@astrojs/sitemap": "^3.1.6",
"@astrojs/tailwind": "^5.1.0",
"astro": "^4.13.1",
"tailwindcss": "^3.4.8",
Expand Down
4 changes: 3 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const subTitle = '若手ものづくり集団 Oysters'
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<meta property="og:type" content="article" />
<meta property="og:url" content={siteUrl} />
<meta name="description" content={subTitle} />
Expand All @@ -27,6 +26,9 @@ const subTitle = '若手ものづくり集団 Oysters'
<meta name="twitter:description" content={subTitle} />
<meta name="twitter:image:src" content={ogpImageUrl} />

<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="sitemap" href="/sitemap-index.xml" />

<title>{title} | {subTitle}</title>
</head>

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))
}

1 comment on commit 7f606fd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.