"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[] } export 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: "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: "Help and Info", submenu: [ { title: "Overview", href: "/docs/help-info" }, { title: "Useful System Commands", href: "/docs/help-info/system-commands" }, { title: "VM and CT Management", href: "/docs/help-info/vm-ct-commands" }, { title: "Storage and Disks", href: "/docs/help-info/storage-commands" }, { title: "Network Commands", href: "/docs/help-info/network-commands" }, { title: "Updates and Packages", href: "/docs/help-info/update-commands" }, { title: "GPU Passthrough", href: "/docs/help-info/gpu-commands" }, { title: "ZFS Management", href: "/docs/help-info/zfs-commands" }, { title: "Backup and Restore", href: "/docs/help-info/backup-commands" }, { title: "System CLI Tools", href: "/docs/help-info/tools-commands" }, ], }, { 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: "Create VM", submenu: [ { title: "Synology VM", href: "/docs/create-vm/synology" }, ], }, { title: "Storage", submenu: [ { title: "Disk Passthrough to a VM", href: "/docs/storage/disk-passthrough-vm" }, { title: "Disk Passthrough to a CT", href: "/docs/storage/disk-passthrough-ct" }, { 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" }, ], }, { title: "About", submenu: [ { title: "Code of Conduct", href: "/docs/about/code-of-conduct" }, { title: "FAQ", href: "/docs/about/faq" }, { title: "Contributors", href: "/docs/about/contributors" }, ], }, { title: "External Repositories", href: "/docs/external-repositories" }, ] 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 (