mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-05-05 23:40:57 +00:00
added breadcrumbs for easier navigation on web
This commit is contained in:
parent
457f9f7b12
commit
49d257ac2c
8 changed files with 62 additions and 99 deletions
47
apps/web/app/(dash)/header/autoBreadCrumbs.tsx
Normal file
47
apps/web/app/(dash)/header/autoBreadCrumbs.tsx
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
"use client";
|
||||
|
||||
import {
|
||||
Breadcrumb,
|
||||
BreadcrumbItem,
|
||||
BreadcrumbLink,
|
||||
BreadcrumbList,
|
||||
BreadcrumbSeparator,
|
||||
} from "@repo/ui/shadcn/breadcrumb";
|
||||
import { usePathname } from "next/navigation";
|
||||
import React from "react";
|
||||
|
||||
function AutoBreadCrumbs() {
|
||||
const pathname = usePathname();
|
||||
|
||||
console.log(pathname.split("/").filter(Boolean));
|
||||
|
||||
return (
|
||||
<Breadcrumb className="hidden md:block">
|
||||
<BreadcrumbList>
|
||||
{!pathname.startsWith("/home") && (
|
||||
<>
|
||||
<BreadcrumbItem>
|
||||
<BreadcrumbLink href="/">Home</BreadcrumbLink>
|
||||
</BreadcrumbItem>
|
||||
<BreadcrumbSeparator hidden={pathname.split("/").length === 1} />
|
||||
</>
|
||||
)}
|
||||
{pathname
|
||||
.split("/")
|
||||
.filter(Boolean)
|
||||
.map((path, idx, paths) => (
|
||||
<>
|
||||
<BreadcrumbItem key={path}>
|
||||
<BreadcrumbLink href={`/${paths.slice(0, idx + 1).join("/")}`}>
|
||||
{path.charAt(0).toUpperCase() + path.slice(1)}
|
||||
</BreadcrumbLink>
|
||||
</BreadcrumbItem>
|
||||
<BreadcrumbSeparator hidden={idx === paths.length - 1} />
|
||||
</>
|
||||
))}
|
||||
</BreadcrumbList>
|
||||
</Breadcrumb>
|
||||
);
|
||||
}
|
||||
|
||||
export default AutoBreadCrumbs;
|
||||
Loading…
Add table
Add a link
Reference in a new issue