"use client" import Link from "next/link" import { usePathname } from "next/navigation" import { useState, useEffect } from "react" import { ChevronDown, ChevronRight, Menu, X } from "lucide-react" interface SubMenuItem { title: string href: string } interface MenuItem { title: string href?: string submenu?: SubMenuItem[] } const sidebarItems: MenuItem[] = [ { title: "Introduction", href: "/docs/introduction" }, { title: "Installation", href: "/docs/installation" }, { title: "Post-Install Script", submenu: [ { title: "Overview", href: "/docs/post-install" }, { title: "Basic Settings", href: "/docs/post-install/basic-settings" }, { title: "System", href: "/docs/post-install/system" }, { title: "Hardware", href: "/docs/post-install/hardware" }, { title: "Virtualization", href: "/docs/post-install/virtualization" }, { title: "Network", href: "/docs/post-install/network" }, { title: "Storage", href: "/docs/post-install/storage" }, { title: "Security", href: "/docs/post-install/security" }, { title: "Customization", href: "/docs/post-install/customization" }, { title: "Monitoring", href: "/docs/post-install/monitoring" }, { title: "Performance", href: "/docs/post-install/performance" }, { title: "Optional", href: "/docs/post-install/optional" }, ], }, { title: "GPUs and Coral", submenu: [ { title: "HW iGPU acceleration to an LXC", href: "/docs/hardware/igpu-acceleration-lxc" }, { title: "Coral TPU to an LXC", href: "/docs/hardware/coral-tpu-lxc" }, { title: "Install Coral TPU on the Host", href: "/docs/hardware/install-coral-tpu-host" }, ], }, { title: "Storage", submenu: [ { title: "Disk Passthrough to a VM", href: "/docs/storage/disk-passthrough-vm" }, { title: "Import Disk Image to a VM", href: "/docs/storage/import-disk-image-vm" }, ], }, { title: "Network", submenu: [ { title: "Repair Network", href: "/docs/network/repair-network" }, { title: "Verify Network", href: "/docs/network/verify-network" }, { title: "Show IP Information", href: "/docs/network/show-ip-information" }, ], }, { title: "Settings ProxMenux", submenu: [ { title: "Change Language", href: "/docs/settings/change-language" }, { title: "Show Version Information", href: "/docs/settings/show-version-information" }, { title: "Uninstall ProxMenux", href: "/docs/settings/uninstall-proxmenux" }, ], }, ] export default function DocSidebar() { const pathname = usePathname() const [openSections, setOpenSections] = useState<{ [key: string]: boolean }>({}) const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false) const toggleSection = (title: string) => { setOpenSections((prev) => ({ ...prev, [title]: !prev[title] })) } const toggleMobileMenu = () => { setIsMobileMenuOpen(!isMobileMenuOpen) } useEffect(() => { const handleResize = () => { if (window.innerWidth >= 768) { setIsMobileMenuOpen(false) } } window.addEventListener("resize", handleResize) return () => window.removeEventListener("resize", handleResize) }, []) const renderMenuItem = (item: MenuItem) => { if (item.submenu) { const isOpen = openSections[item.title] || false return (