Skip to content

Commit

Permalink
Add robots.txt and sitemap.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Sep 20, 2023
1 parent cdccc02 commit 5ea2986
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/routes/_seo+/robots[.]txt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { generateRobotsTxt } from '@nasa-gcn/remix-seo'
import { type DataFunctionArgs } from '@remix-run/node'

export function loader({ request }: DataFunctionArgs) {
const origin = new URL(request.url).origin
return generateRobotsTxt([
{ type: 'sitemap', value: `${origin}/sitemap.xml` },
])
}
19 changes: 19 additions & 0 deletions app/routes/_seo+/sitemap[.]xml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*!
* Copyright © 2023 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
import { generateSitemap } from '@nasa-gcn/remix-seo'
import { routes } from '@remix-run/dev/server-build'
import { type LoaderFunctionArgs } from '@remix-run/node'

export function loader({ request }: LoaderFunctionArgs) {
return generateSitemap(request, routes, {
siteUrl: new URL(request.url).origin,
headers: {
'Cache-Control': `public, max-age=${60 * 5}`,
},
})
}
16 changes: 14 additions & 2 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 @@ -45,6 +45,7 @@
"@conform-to/zod": "^0.9.0",
"@epic-web/remember": "^1.0.2",
"@epic-web/totp": "^1.1.1",
"@nasa-gcn/remix-seo": "^2.0.0",
"@paralleldrive/cuid2": "^2.2.2",
"@prisma/client": "^5.3.1",
"@radix-ui/react-checkbox": "^1.0.4",
Expand Down

0 comments on commit 5ea2986

Please sign in to comment.