Skip to content

Commit

Permalink
fix: exclude invalid dynamic params when generating alternates
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre committed May 1, 2024
1 parent f11c640 commit daa6ad2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"editor.defaultFormatter": "biomejs.biome",
"[mdx]": {
"editor.defaultFormatter": "unifiedjs.vscode-mdx"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
25 changes: 11 additions & 14 deletions package/src/sitemap/generate-sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,21 @@ export function generateSitemap(
}

const index = route.pages.indexOf(page);
const sitemapOptions = route.sitemapOptions[index];
if (!sitemapOptions) {
const sitemapOptions = route.sitemapOptions.filter(
(e) =>
e.dynamicParams &&
(Array.isArray(e.dynamicParams)
? e.dynamicParams
: Object.entries(e.dynamicParams)
).length > 0,
)[index];
if (!sitemapOptions || !sitemapOptions.dynamicParams) {
return [];
}

for (const equivalentRoute of equivalentRoutes) {
const options = normalizeDynamicParams(
sitemapOptions?.dynamicParams,
).find((e) => e.locale === equivalentRoute.route.locale);

// TODO: remove
console.dir(
{
page,
options,
sitemapOptions: normalizeDynamicParams(sitemapOptions?.dynamicParams),
},
{ depth: null },
const options = normalizeDynamicParams(sitemapOptions.dynamicParams).find(
(e) => e.locale === equivalentRoute.route.locale,
);

if (!options) {
Expand Down

0 comments on commit daa6ad2

Please sign in to comment.