Duplicate urls returned by `generateRemixSitemap` using React Router 7
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- react, typescript
Research direction
Start at the generateRemixSitemap call in the provided loader and compare the routes from virtual:react-router/server-build with the routes.ts configuration. Reproduce the generated XML with the shown React Router 7 setup, trace where duplicate paths enter the helper, and verify that each sitemap URL appears only once.
Written by the indexing model from the issue text.
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?
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",
},
});
};
// 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:
<url>
<loc>http://localhost:5173/</loc>
</url>
<url>
<loc>http://localhost:5173/</loc>
</url>
<url>
<loc>http://localhost:5173/chat</loc>
</url>
<url>
<loc>http://localhost:5173/blog</loc>
</url>
<url>
<loc>http://localhost:5173/</loc>
</url>
- Dominant language
- TypeScript
- Stars
- 96
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from code-forge-io/seo-tools
-
Global handle function for Remix/React Router v7Possibly taken @mateussilva92 claimed this 313 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
code-forge-io/seo-tools#18 ·
-
Meta with React 19Open
Difficulty 4/5 3-5 days Newbie friendliness 30/100
code-forge-io/seo-tools#17 ·
-
RR7 splat routesOpen
Difficulty 3/5 1-2 days Newbie friendliness 35/100
code-forge-io/seo-tools#16 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
code-forge-io/seo-tools#13 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
code-forge-io/seo-tools#8 · 2 comments ·
All issues in code-forge-io/seo-tools
Similar issues
-
area:cli area:security bug priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
"code source" and "numerique.gouv" links: "new window" mention duplicated in the accessible nameOpenaccessibility
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
numerique-gouv/lasuite-landingpage#315 ·
Maintainers usually reply within 1 day
-
needs:triage
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
HyeokjaeChoi/vaultme#585 ·
Maintainers usually reply within 1 day
-
enhancement priority/P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
beettlle/pi-smart-router#200 ·