'use client' import { SidebarContentArticleLink, SidebarContentCategoryLink, SidebarContentLink, SidebarContentList, SidebarContentSectionLink, } from '@/types/content-types' import Link from 'next/link' import { usePathname } from 'next/navigation' import { createContext, useContext, useEffect } from 'react' import { Search } from './Search' import { SidebarCloseButton } from './SidebarCloseButton' import { ToggleMenuButton } from './ToggleMenuButton' type SidebarProps = SidebarContentList const activeLinkContext = createContext(null) export function Sidebar({ links, sectionId, categoryId, articleId }: SidebarProps) { const activeId = articleId ?? categoryId ?? sectionId const pathName = usePathname() useEffect(() => { document.body.classList.remove('sidebar-open') }, [pathName]) return ( <>
e.stopPropagation()}>
) } export function SidebarLinks({ links }: { links: SidebarContentLink[] }) { return ( ) } function SidebarLink(props: SidebarContentLink) { switch (props.type) { case 'section': { return } case 'article': { return } case 'category': { return } } } function SidebarSection({ title, children }: SidebarContentSectionLink) { if (children.length === 0) return null return (
  • {title && ( {title} )}
      {children.map((link) => ( ))}
  • ) } function SidebarCategory({ title, children }: SidebarContentCategoryLink) { if (children.length === 0) return null return (
  • {title}
      {children.map((link) => ( ))}

  • ) } function SidebarArticle({ title, url, articleId }: SidebarContentArticleLink) { const isActive = useContext(activeLinkContext) === articleId return (
  • {title}
  • ) }