interface FilesBreadcrumbProps {
path: string;
isShowingNotes?: boolean;
}
export default function FilesBreadcrumb({ path, isShowingNotes }: FilesBreadcrumbProps) {
const routePath = isShowingNotes ? 'notes' : 'files';
if (!isShowingNotes && path === '/') {
return (
All files
);
}
if (isShowingNotes && path === '/Notes/') {
return (
All notes
);
}
const pathParts = path.slice(1, -1).split('/');
if (isShowingNotes) {
pathParts.shift();
}
return (
{isShowingNotes ? All notes : All files}
{pathParts.map((part, index) => {
if (index === pathParts.length - 1) {
return (
<>
/
{decodeURIComponent(part)}
>
);
}
const fullPathForPart: string[] = [];
for (let pathPartIndex = 0; pathPartIndex <= index; ++pathPartIndex) {
fullPathForPart.push(pathParts[pathPartIndex]);
}
return (
<>
/
{decodeURIComponent(part)}
>
);
})}
);
}