import { Heading, NavList } from '@primer/react' import { useEffect, useState } from 'react' import cx from 'classnames' import type { MiniTocItem } from 'components/context/ArticleContext' import { useTranslation } from 'components/hooks/useTranslation' import styles from './Minitocs.module.scss' export type MiniTocsPropsT = { miniTocItems: MiniTocItem[] } function RenderTocItem(item: MiniTocItem) { const [currentAnchor, setCurrentAnchor] = useState('') useEffect(() => { const onHashChanged = () => { setCurrentAnchor(window.location.hash) } window.addEventListener('hashchange', onHashChanged) return () => { window.removeEventListener('hashchange', onHashChanged) } }, []) return (