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 'src/languages/components/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 ( <> {item.contents.title} {item.items && item.items.length > 0 && ( )} ) } export function MiniTocs({ miniTocItems }: MiniTocsPropsT) { const { t } = useTranslation('pages') return ( <> {t('miniToc')} {miniTocItems.map((items, i) => { return ( ) })} ) }