"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useState } from "react"; const navItems = [ { label: "首页", href: "/" }, { label: "文章", href: "/blog" }, { label: "分类", href: "/categories" }, { label: "标签", href: "/tags" }, { label: "关于", href: "/about" }, ]; export default function Header() { const pathname = usePathname(); const [menuOpen, setMenuOpen] = useState(false); return (
{/* Mobile menu */} {menuOpen && (
{navItems.map((item) => { const isActive = pathname === item.href || (item.href !== "/" && pathname.startsWith(item.href)); return ( setMenuOpen(false)} className={` block py-3 px-2 font-sans text-sm tracking-wide border-b border-warm-gray/10 transition-colors duration-300 ${isActive ? "text-terracotta" : "text-ink-muted"} `} > {item.label} ); })}
)}
); }