"use client"; import type { RemixiconComponentType } from "@remixicon/react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import type * as React from "react"; import { SidebarGroup, SidebarGroupContent, SidebarMenu, SidebarMenuButton, SidebarMenuItem, } from "@/components/ui/sidebar"; export function NavSecondary({ items, ...props }: { items: { title: string; url: string; icon: RemixiconComponentType; }[]; } & React.ComponentPropsWithoutRef) { const pathname = usePathname(); return ( {items.map((item) => { const normalizedPathname = pathname.endsWith("/") && pathname !== "/" ? pathname.slice(0, -1) : pathname; const normalizedUrl = item.url.endsWith("/") && item.url !== "/" ? item.url.slice(0, -1) : item.url; const itemIsActive = normalizedPathname === normalizedUrl || normalizedPathname.startsWith(`${normalizedUrl}/`); return ( {item.title} ); })} ); }