"use client"; import { useState, useEffect } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { DEFAULT_SECTIONS, type SectionConfig } from "@mcpedia/config/sections"; import ThemeToggle from "@/components/ThemeToggle"; import CommandMenu from "@/components/CommandMenu"; import { Plus, Search, Menu, X, Lock, } from "lucide-react"; export default function Header() { const pathname = usePathname(); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const [sections, setSections] = useState(DEFAULT_SECTIONS); useEffect(() => { fetch("/api/sections") .then((r) => r.json()) .then((data) => { if (Array.isArray(data) && data.length > 0) { setSections(data); } }) .catch(() => {}); }, []); return (
{/* Brand */}
M
MCPedia CORE::DB
{/* Center: Desktop Sections Nav */} {/* Right Tools & Navigation Deck */}
New Doc Admin
{/* Mobile menu toggle */}
{/* Mobile Drawer */} {mobileMenuOpen && (
Knowledge Sections
{sections.map((s) => { const isActive = pathname === `/${s.id}` || pathname.startsWith(`/${s.id}/`); return ( setMobileMenuOpen(false)} className={`flex items-center gap-2 px-3 py-2 rounded-md text-xs font-medium transition-colors ${ isActive ? "bg-[var(--bg-elevated)] text-[var(--text-primary)] border border-[var(--border-color)] font-semibold" : "text-[var(--text-secondary)] hover:bg-[var(--bg-elevated)] hover:text-[var(--text-primary)]" }`} > {s.icon} {s.label} ); })}
setMobileMenuOpen(false)} className="flex-1 flex items-center justify-center gap-1.5 py-2 text-xs bg-[var(--bg-elevated)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] rounded-md font-medium border border-[var(--border-color)]" > Search setMobileMenuOpen(false)} className="flex-1 flex items-center justify-center gap-1.5 py-2 text-xs bg-[var(--brand)] text-[var(--brand-fg)] rounded-md font-semibold shadow-xs" > Create Doc
)}
); }