Add dynamic breadcrumb navigation and update kanzlei routes under /demo
This commit is contained in:
28
internal_frontend/utils/BreadcrumbUtils.ts
Normal file
28
internal_frontend/utils/BreadcrumbUtils.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// utils/getBreadcrumbs.ts
|
||||
import {breadcrumbMap} from '@/lib/breadcrumb-map';
|
||||
|
||||
export type Breadcrumb = {
|
||||
label: string;
|
||||
href: string;
|
||||
isCurrentPage?: boolean;
|
||||
};
|
||||
|
||||
export function getBreadcrumbs(path: string): Breadcrumb[] {
|
||||
const pathSegments = path.split('/').filter(Boolean);
|
||||
|
||||
return pathSegments.map((segment, index) => {
|
||||
const href = `/${pathSegments.slice(0, index + 1).join('/')}`;
|
||||
// Use the mapping if it exists, otherwise format the segment
|
||||
const label = breadcrumbMap[segment.toLowerCase()] ||
|
||||
segment
|
||||
.split('-')
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
|
||||
return {
|
||||
label,
|
||||
href,
|
||||
isCurrentPage: index === pathSegments.length - 1
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user