diff options
Diffstat (limited to 'src/components/ToC/ToC.tsx')
| -rw-r--r-- | src/components/ToC/ToC.tsx | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/src/components/ToC/ToC.tsx b/src/components/ToC/ToC.tsx deleted file mode 100644 index b172b3a..0000000 --- a/src/components/ToC/ToC.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { t } from '@lingui/macro'; -import { Heading } from '@ts/types/app'; -import useHeadingsTree from '@utils/hooks/useHeadingsTree'; -import styles from './ToC.module.scss'; - -const ToC = () => { - const headingsTree = useHeadingsTree('article'); - const title = t`Table of contents`; - - const getItems = (headings: Heading[]) => { - return headings.map((heading) => { - return ( - <li key={heading.id}> - <a href={`#${heading.id}`}>{heading.title}</a> - {heading.children.length > 0 && <ol>{getItems(heading.children)}</ol>} - </li> - ); - }); - }; - - return ( - <div className={styles.wrapper}> - <h2>{title}</h2> - <ol className={styles.list}>{getItems(headingsTree)}</ol> - </div> - ); -}; - -export default ToC; |
