Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvuGvHpbAQ4syfuLuRvutL
26 lines
1 KiB
TypeScript
26 lines
1 KiB
TypeScript
"use client";
|
|
import Link from "next/link";
|
|
import { usePathname } from "next/navigation";
|
|
import { Icon } from "../Icon";
|
|
import type { NavItem } from "./nav";
|
|
|
|
export function AdminNav({ groups, badges }: { groups: { group: string; items: NavItem[] }[]; badges: Record<string, number> }) {
|
|
const pathname = usePathname();
|
|
const active = (href: string) => (href === "/admin" ? pathname === "/admin" : pathname === href || pathname.startsWith(href + "/"));
|
|
return (
|
|
<nav className="ad-nav" aria-label="Admin-Navigation">
|
|
{groups.map((g) => (
|
|
<div key={g.group} style={{ display: "contents" }}>
|
|
{g.group && <div className="ad-nav__group">{g.group}</div>}
|
|
{g.items.map((i) => (
|
|
<Link key={i.href} href={i.href} aria-current={active(i.href) ? "page" : undefined}>
|
|
<Icon name={i.icon} />
|
|
{i.label}
|
|
{i.badge && badges[i.badge] > 0 && <span className="ad-nav__badge">{badges[i.badge]}</span>}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
))}
|
|
</nav>
|
|
);
|
|
}
|