import {useState} from 'react'; import Link from 'next/link'; import NavHeader from './NavHeader'; import type {HeadingInfo} from '@sup39/rehype-mdx-export-headings'; import config from '#config'; export type NavEntryInfo = { name: string link: string children?: NavEntryInfo[]|null }; export function NavEntry({ entry: {name, link, children}, dir, here, children: childrenJSX, }: {entry: NavEntryInfo, dir: string, here: string, children?: Body}) { const [toggle, setToggle] = useState(false); const href = dir+link; const isHere = href.replace(/\/$/, '')===here; // remove trailing slash const entryCls = 'nav-entry'+(isHere ? ' nav-here' : ''); return children?.length ?
<>
{name} setToggle(e=>!e)}>
{isHere ? childrenJSX : <>}
{ children.map(entry => {childrenJSX}) }
:
{name}
; } export default function Nav({children, headings, pathname}: { children?: JSX.Element headings: HeadingInfo[] pathname: string }) { const [navFold, setNavFold] = useState(false); const headingsJSX = ; return ; }