Files
t3code/apps/web/src/components/files/filePath.ts
T

18 lines
536 B
TypeScript

export interface FileBreadcrumb {
label: string;
path: string;
kind: "project" | "directory" | "file";
}
export function fileBreadcrumbs(projectName: string, relativePath: string): FileBreadcrumb[] {
const parts = relativePath.split("/").filter(Boolean);
return [
{ label: projectName, path: "", kind: "project" },
...parts.map((part, index) => ({
label: part,
path: parts.slice(0, index + 1).join("/"),
kind: index === parts.length - 1 ? ("file" as const) : ("directory" as const),
})),
];
}