import { REFERENCES } from '~/content/navigation.references' import { ArrowLeft, ChevronRight } from 'lucide-react' import Image from 'next/legacy/image' import Link from 'next/link' import { usePathname } from 'next/navigation' import { Accordion } from 'radix-ui' import { NavMenuGroup, NavMenuSection } from './Navigation.types' const SideBar = ({ menuItems = [] }: { menuItems: any }) => { const pathname = usePathname() const pathSegments = pathname.split('/') const isInReferencePages = pathSegments.includes('reference') && pathSegments.length >= 3 const referenceMeta = pathSegments.length >= 3 ? REFERENCES[pathSegments[2]] : undefined const currentSection: NavMenuGroup = menuItems.find((group) => { const foundItem = group.items.find((section) => { if (section.items.length > 0) { const foundSubItem = section.items.find((item) => { if (item.url === pathname) return item }) if (foundSubItem) return section } else { if (section.url === pathname) return section } }) if (foundItem) return group }) const currentSubSection: NavMenuSection | undefined = currentSection !== undefined ? currentSection.items.find((section) => { if (section.items.length === 0) { return undefined } else { return section.items.find((item) => { if (item.url === pathname) return item }) } }) : undefined return (
{referenceMeta.name}