Skip to content

Commit

Permalink
🐛 fix breadcrumbs (#2750)
Browse files Browse the repository at this point in the history
  • Loading branch information
BorghildSelle authored Jan 16, 2025
1 parent bac3b05 commit 39f1164
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions web/core/Breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ const buildJsonLdElements = (crumbs: Breadcrumb[], router: ReturnType<typeof use
}))
}

const capitalize = (text: string): string => text[0].toUpperCase() + text.slice(1)
const capitalize = (text: string): string => text?.[0].toUpperCase() + text?.slice(1)

const parseBreadcrumbs = (crumbs: Breadcrumb[]) => {
return crumbs.map((item) => ({
...item,
label: capitalize(item.label),
}))
return crumbs
.filter((item) => item?.slug && item?.label)
.map((item) => {
return {
...item,
label: capitalize(item.label),
}
})
}

export const Breadcrumbs = ({
Expand Down Expand Up @@ -76,4 +80,4 @@ export const Breadcrumbs = ({
<BreadcrumbJsonLd itemListElements={buildJsonLdElements(crumbs, router)} />
</BackgroundContainer>
)
}
}

0 comments on commit 39f1164

Please sign in to comment.