code-forge-io / code-forge-io/seo-tools
Duplicate urls returned by `generateRemixSitemap` using React Router 7
- Dominant language
- TypeScript
- Stars
- 94
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Hi @AlemTuzlak, first of thanks for the package!
I do not know if its only related to RR7 or Remix v2 aswell, but when I use the following code to generate the sitemap, the `generateRemixSitemap` helper function returns duplicate links. Any chance to fix this or do you know why that is happening?
```ts
import { generateRemixSitemap } from "@forge42/seo-tools/remix/sitemap";
import type { Route } from "./+types/sitemap.xml";
import { href } from "react-router";
export const loader = async ({ request }: Route.LoaderArgs) => {
const { routes } = await import("virtual:react-router/server-build");
const sitemap = await generateRemixSitemap({
domain: new URL(request.url).origin,
ignore: [href("/api/chat"), href("/legal-notice"), href("/privacy-policy")],
// @ts-expect-error Type mismatch, maybe related to a stricter type mentioned in release notes for v.7.0.0
// https://github.com/forge-42/seo-tools/issues/8
routes,
});
return new Response(sitemap, {
headers: {
"Content-Type": "application/xml",
},
});
};
```
```ts
// routes.ts
import {
type RouteConfig,
index,
layout,
prefix,
route,
} from "@react-router/dev/routes";
export default [
layout("routes/layout.tsx", [
index("routes/index.tsx"),
...
route("sitemap.xml", "routes/sitemap.xml.ts"),
route("robots.txt", "routes/robots.txt.ts"),
]),
] satisfies RouteConfig;
```
The generated sitemap:
```xml
http://localhost:5173/
http://localhost:5173/
http://localhost:5173/chat
http://localhost:5173/blog
http://localhost:5173/
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.