import type { FlexProps } from '@chakra-ui/react'; import { Flex, useColorModeValue } from '@chakra-ui/react'; import { useScrollSpy } from '@site/hooks/useScrollSpy'; import type { TOC } from '@site/types/Docs'; import { Link } from './Link'; type TocProps = { toc: TOC; } & FlexProps; export const Toc = ({ toc, ...props }: TocProps) => { const activeId = useScrollSpy( toc.map(({ id }) => `[id="${id}"]`), { rootMargin: '0% 0% -50% 0%', }, ); const inActiveBorderColor = useColorModeValue('gray.100', 'gray.600'); return ( {toc.map(({ id, content, indent }) => ( {content} ))} ); };