From abc9e948acb857054ab1e31301d030392e2d87cc Mon Sep 17 00:00:00 2001 From: Minhaz Date: Sat, 12 Oct 2024 19:47:02 +0600 Subject: [PATCH] feat: add breadcrumb --- components/shared/Breadcrumb.tsx | 57 ++++++++++++++++++++++++++++++++ components/shared/Navbar.tsx | 6 ++-- components/shared/index.ts | 3 +- public/sw.js | 2 +- public/sw.js.map | 2 +- 5 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 components/shared/Breadcrumb.tsx diff --git a/components/shared/Breadcrumb.tsx b/components/shared/Breadcrumb.tsx new file mode 100644 index 0000000..aa81153 --- /dev/null +++ b/components/shared/Breadcrumb.tsx @@ -0,0 +1,57 @@ +"use client"; + +import { usePathname } from "next/navigation"; +import Link from "next/link"; +import { ChevronRight, Home, FileText } from "lucide-react"; + +const truncateText = (text: string, maxLength: number) => { + return text.length > maxLength ? text.slice(0, maxLength) + "..." : text; +}; + +export default function Breadcrumb() { + const pathname = usePathname(); + const pathSegments = pathname.split("/").filter((segment) => segment !== ""); + + return ( + + ); +} diff --git a/components/shared/Navbar.tsx b/components/shared/Navbar.tsx index 50a916a..cf6e62f 100644 --- a/components/shared/Navbar.tsx +++ b/components/shared/Navbar.tsx @@ -15,18 +15,18 @@ import { } from "@/components/ui/dropdown-menu"; import { useContext } from "react"; import { MainContext } from "@/contexts/MainContext"; -import { Notification, SearchBar } from "."; +import { Notification, Breadcrumb } from "."; export default function Navbar() { const { handleLang, lang, openSidebar } = useContext(MainContext); return ( -