diff --git a/src/components/Breadcrumbs/index.tsx b/src/components/Breadcrumbs/index.tsx index 8923a4796b0..6f0dea0cc25 100644 --- a/src/components/Breadcrumbs/index.tsx +++ b/src/components/Breadcrumbs/index.tsx @@ -1,19 +1,22 @@ +import { Fragment } from "react" import { useRouter } from "next/router" import { useTranslation } from "next-i18next" -import { - Breadcrumb, - BreadcrumbItem, - BreadcrumbLink, - type BreadcrumbProps as ChakraBreadcrumbProps, -} from "@chakra-ui/react" import type { Lang } from "@/lib/types" -import { BaseLink } from "@/components/Link" - import { isLangRightToLeft } from "@/lib/utils/translations" -export type BreadcrumbsProps = ChakraBreadcrumbProps & { +import { + Breadcrumb, + BreadcrumbItem, + BreadcrumbLink, + BreadcrumbList, + BreadcrumbPage, + BreadcrumbProps, + BreadcrumbSeparator, +} from "../ui/breadcrumb" + +export type BreadcrumbsProps = BreadcrumbProps & { slug: string startDepth?: number } @@ -65,23 +68,28 @@ const Breadcrumbs = ({ slug, startDepth = 0, ...props }: BreadcrumbsProps) => { return ( - {crumbs.map(({ fullPath, text }) => { - const isCurrentPage = slug === fullPath - return ( - - - {text} - - - ) - })} + + {crumbs.map(({ fullPath, text }) => { + const normalizePath = (path) => path.replace(/\/$/, "") // Remove trailing slash + const isCurrentPage = normalizePath(slug) === normalizePath(fullPath) + return ( + + + {isCurrentPage ? ( + {text} + ) : ( + {text} + )} + + {!isCurrentPage && ( + + / + + )} + + ) + })} + ) } diff --git a/src/components/ui/breadcrumb.tsx b/src/components/ui/breadcrumb.tsx new file mode 100644 index 00000000000..2ff4246f2e4 --- /dev/null +++ b/src/components/ui/breadcrumb.tsx @@ -0,0 +1,124 @@ +import * as React from "react" +import Link, { LinkProps } from "next/link" +import { LuChevronRight, LuMoreHorizontal } from "react-icons/lu" +import { Slot } from "@radix-ui/react-slot" + +import { cn } from "@/lib/utils/cn" + +interface BreadcrumbProps extends React.ComponentPropsWithoutRef<"nav"> { + separator?: React.ReactNode +} +const Breadcrumb = React.forwardRef( + ({ ...props }, ref) =>