"use client"; import type { ReactNode } from "react"; import { usePathname } from "next/navigation"; import { NavLink } from "@mantine/core"; import { Link } from "@homarr/ui"; export const CommonNavLink = (props: ClientNavigationLink) => "href" in props ? : ; const NavLinkHref = (props: NavigationLinkHref) => { const pathname = usePathname(); return props.external ? ( ) : ( ); }; const NavLinkWithItems = (props: NavigationLinkWithItems) => { const pathname = usePathname(); const isActive = props.items.some((item) => item.href === pathname); return ( {props.items.map((item) => ( ))} ); }; interface CommonNavigationLinkProps { label: string; icon: ReactNode; } interface NavigationLinkHref extends CommonNavigationLinkProps { href: string; external?: boolean; } interface NavigationLinkWithItems extends CommonNavigationLinkProps { items: NavigationLinkHref[]; } export type ClientNavigationLink = NavigationLinkHref | NavigationLinkWithItems;