Skip to content

Commit

Permalink
fix(storefront): Adding breadcrumb for parent category on category pages
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Sep 27, 2024
1 parent c2367b6 commit cb6f954
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/storefront/src/lib/composables/use-breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ const useBreadcrumbs = async (props: Props = {}) => {
});
}
});
} else {
const pageCategory = (apiDoc as Categories);
if (pageCategory.parent) {
const parentCategory = categories?.find((category) => {
return category.name === pageCategory.parent!.name;
});
if (parentCategory?.slug) {
breadcrumbs.push({
name: getName(parentCategory),
link: `/${parentCategory.slug}`,
});
}
}
}
breadcrumbs.push({
name: getName(apiDoc),
Expand Down

0 comments on commit cb6f954

Please sign in to comment.