mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-26 13:26:22 +00:00
25 lines
668 B
TypeScript
25 lines
668 B
TypeScript
|
import { QuartzComponentProps } from "./types"
|
||
|
import style from "./styles/toc.scss"
|
||
|
|
||
|
export default function TableOfContents({ fileData, position }: QuartzComponentProps) {
|
||
|
if (!fileData.toc) {
|
||
|
return null
|
||
|
}
|
||
|
|
||
|
if (position === 'body') {
|
||
|
// TODO: animate this
|
||
|
return <details className="toc" open>
|
||
|
<summary><h3>Table of Contents</h3></summary>
|
||
|
<ul>
|
||
|
{fileData.toc.map(tocEntry => <li key={tocEntry.slug} className={`depth-${tocEntry.depth}`}>
|
||
|
<a href={`#${tocEntry.slug}`}>{tocEntry.text}</a>
|
||
|
</li>)}
|
||
|
</ul>
|
||
|
</details>
|
||
|
} else if (position === 'sidebar') {
|
||
|
// TODO
|
||
|
}
|
||
|
}
|
||
|
|
||
|
TableOfContents.css = style
|