diff --git a/app/routes/_seo+/robots[.]txt.ts b/app/routes/_seo+/robots[.]txt.ts new file mode 100644 index 000000000..2abd727db --- /dev/null +++ b/app/routes/_seo+/robots[.]txt.ts @@ -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` }, + ]) +} diff --git a/app/routes/_seo+/sitemap[.]xml.ts b/app/routes/_seo+/sitemap[.]xml.ts new file mode 100644 index 000000000..a16423643 --- /dev/null +++ b/app/routes/_seo+/sitemap[.]xml.ts @@ -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}`, + }, + }) +} diff --git a/package-lock.json b/package-lock.json index f4216e017..eeb60610e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@conform-to/zod": "^0.9.0", "@epic-web/remember": "^1.0.2", "@epic-web/totp": "^1.1.0", + "@nasa-gcn/remix-seo": "^2.0.0", "@paralleldrive/cuid2": "^2.2.2", "@prisma/client": "^5.3.1", "@radix-ui/react-checkbox": "^1.0.4", @@ -33,7 +34,6 @@ "better-sqlite3": "^8.6.0", "cachified": "^3.5.4", "chalk": "^5.3.0", - "chokidar": "^3.5.3", "class-variance-authority": "^0.7.0", "close-with-grace": "^1.2.0", "clsx": "^2.0.0", @@ -100,6 +100,7 @@ "@types/source-map-support": "^0.5.7", "@vitejs/plugin-react": "^4.0.4", "@vitest/coverage-v8": "^0.34.4", + "chokidar": "^3.5.3", "cookie": "^0.5.0", "enforce-unique": "^1.1.1", "esbuild": "^0.19.3", @@ -2180,6 +2181,18 @@ "node": ">=18" } }, + "node_modules/@nasa-gcn/remix-seo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@nasa-gcn/remix-seo/-/remix-seo-2.0.0.tgz", + "integrity": "sha512-jawoxrjMMbFGgj20d61KblrQNkSFcW2yP7vWWQn2a+eK2J8uYYbw99j2GD7A4XbpQUxy7dg0yvRVsYYJ5uZnLQ==", + "dependencies": { + "lodash": "^4.17.21" + }, + "peerDependencies": { + "@remix-run/react": "^1.0.0 || ^2.0.0", + "@remix-run/server-runtime": "^1.0.0 || ^2.0.0" + } + }, "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { "version": "5.1.1-v1", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", @@ -11999,8 +12012,7 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "node_modules/lodash.camelcase": { "version": "4.3.0", diff --git a/package.json b/package.json index 0f6678e74..7a779583e 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "@conform-to/zod": "^0.9.0", "@epic-web/remember": "^1.0.2", "@epic-web/totp": "^1.1.0", + "@nasa-gcn/remix-seo": "^2.0.0", "@paralleldrive/cuid2": "^2.2.2", "@prisma/client": "^5.3.1", "@radix-ui/react-checkbox": "^1.0.4",