import React from 'react'; import classNames from 'classnames'; import { NavLink, useParams, useLocation } from 'remix'; import { getFolderPages, Heading, Config } from '~/utils'; import { useConfig } from '../ConfigProvider'; import { CreatedInCurvenote } from '../curvenote'; import { useNavOpen } from '../UiStateProvider'; type Props = { folder?: string; headings: Heading[]; sections?: Config['site']['sections']; }; const HeadingLink = ({ path, isIndex, children, }: { path: string; isIndex?: boolean; children: React.ReactNode; }) => { const { pathname } = useLocation(); const exact = pathname === path; const [, setOpen] = useNavOpen(); return ( classNames('block', { 'text-blue-500': !isIndex && isActive, 'font-semibold': isActive, 'hover:text-slate-800 dark:hover:text-slate-100': !isActive, 'border-b pb-1': isIndex, 'border-stone-200 dark:border-stone-700': isIndex && !exact, 'border-blue-500': isIndex && exact, }) } to={path} suppressHydrationWarning // The pathname is not defined on the server always. onClick={() => { // Close the nav panel if it is open setOpen(false); }} > {children} ); }; const HEADING_CLASSES = 'text-slate-900 text-lg leading-6 dark:text-slate-100'; const Headings = ({ folder, headings, sections }: Props) => { const secs = sections ?? [{ folder, title: 'Unknown' }]; return ( ); }; export const LeftNav = () => { const [open] = useNavOpen(); const config = useConfig(); const { folder: folderName } = useParams(); const headings = getFolderPages(config, folderName); if (!headings) return null; return (
); };