Add dynamic breadcrumb navigation and update kanzlei routes under /demo

This commit is contained in:
2025-07-02 01:25:55 +09:00
parent b33b470e7b
commit 0b2f8332a2
11 changed files with 246 additions and 8 deletions

View 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
};
});
}