Skip to content

Commit dd78a18

Browse files
committed
fix: fix sitemap.xml url path generation
1 parent fa46334 commit dd78a18

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.changeset/dull-radios-dress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@blinkk/root': patch
3+
---
4+
5+
fix: fix sitemap.xml url path generation

packages/root/src/render/render.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,16 +387,23 @@ export class Renderer {
387387
async getSitemap(): Promise<Sitemap> {
388388
const sitemap: Sitemap = {};
389389
const sitemapItemAlts: Record<string, Record<string, string>> = {};
390+
const trailingSlash = this.rootConfig.server?.trailingSlash || false;
390391

391392
await this.router.walk(async (urlPath: string, route: Route) => {
392393
const routePaths = await this.router.getAllPathsForRoute(urlPath, route);
393394
routePaths.forEach((routePath) => {
394395
const routeLocale = route.isDefaultLocale ? 'x-default' : route.locale;
395-
const defaultUrlPath = replaceParams(route.routePath, routePath.params);
396+
const defaultUrlPath = normalizeUrlPath(
397+
replaceParams(route.routePath, routePath.params),
398+
{trailingSlash: trailingSlash}
399+
);
396400
if (!sitemapItemAlts[defaultUrlPath]) {
397401
sitemapItemAlts[defaultUrlPath] = {};
398402
}
399-
sitemapItemAlts[defaultUrlPath][routeLocale] = urlPath;
403+
sitemapItemAlts[defaultUrlPath][routeLocale] = normalizeUrlPath(
404+
replaceParams(urlPath, routePath.params),
405+
{trailingSlash: trailingSlash}
406+
);
400407
const sitemapItem: SitemapItem = {
401408
urlPath: routePath.urlPath,
402409
route,

0 commit comments

Comments
 (0)