From d768d108d64cb0d625c00756efdcc5c8b27c5e1f Mon Sep 17 00:00:00 2001 From: gbanyan Date: Fri, 21 Nov 2025 01:10:15 +0800 Subject: [PATCH] Add nested navigation groups --- components/nav-menu.tsx | 81 +++++++++++++++++++++++++++++--------- components/site-header.tsx | 55 ++++++++++++++++++++++---- next-env.d.ts | 2 +- 3 files changed, 112 insertions(+), 26 deletions(-) diff --git a/components/nav-menu.tsx b/components/nav-menu.tsx index 380245d..6133dd1 100644 --- a/components/nav-menu.tsx +++ b/components/nav-menu.tsx @@ -14,7 +14,8 @@ import { FiTag, FiServer, FiCpu, - FiList + FiList, + FiChevronDown } from 'react-icons/fi'; import Link from 'next/link'; @@ -47,9 +48,10 @@ const ICON_MAP: Record = { export interface NavLinkItem { key: string; - href: string; - label?: string; + href?: string; + label: string; iconKey: IconKey; + children?: NavLinkItem[]; } interface NavMenuProps { @@ -62,6 +64,21 @@ export function NavMenu({ items }: NavMenuProps) { const toggle = () => setOpen((val) => !val); const close = () => setOpen(false); + const renderChild = (item: NavLinkItem) => { + const Icon = ICON_MAP[item.iconKey] ?? FiFile; + return item.href ? ( + + + {item.label} + + ) : null; + }; + return (
+ + {/* Desktop dropdown */} +
+
+ {item.children.map((child) => renderChild(child))} +
+
+ + {/* Mobile inline list */} +
+ {item.children.map((child) => renderChild(child))} +
+
+ ); + } + + return item.href ? ( + + + {item.label} +