Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-02-18 10:12:07 +01:00
parent 8692482376
commit 53bceb5479
5 changed files with 47 additions and 30 deletions

View File

@@ -15,7 +15,10 @@ import {
SidebarProvider,
SidebarTrigger,
} from "@/components/ui/sidebar";
import { BreadcrumbProvider, useBreadcrumb } from "@/contexts/BreadcrumbContext";
import {
BreadcrumbProvider,
useBreadcrumb,
} from "@/contexts/BreadcrumbContext";
function BreadcrumbNavigation() {
const location = useLocation();
@@ -26,10 +29,10 @@ function BreadcrumbNavigation() {
// Check if we have a custom segment name
const fullPath = pathSegments
.slice(0, pathSegments.indexOf(segment) + 1)
.join('/');
.join("/");
// Look for patterns like 'vendors/:id' in our segments
const patternPath = fullPath.replace(/\/[^/]+$/, '/:id');
const patternPath = fullPath.replace(/\/[^/]+$/, "/:id");
if (segments[patternPath]) {
return segments[patternPath];
}
@@ -60,9 +63,7 @@ function BreadcrumbNavigation() {
</BreadcrumbPage>
) : (
<BreadcrumbLink asChild>
<Link to={path}>
{getBreadcrumbText(segment, path)}
</Link>
<Link to={path}>{getBreadcrumbText(segment, path)}</Link>
</BreadcrumbLink>
)}
</BreadcrumbItem>