mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 19:46:23 +00:00
19 lines
524 B
TypeScript
19 lines
524 B
TypeScript
import { QuartzComponentProps } from "./types"
|
|
import style from "./styles/toc.scss"
|
|
|
|
export default function TableOfContents({ fileData }: QuartzComponentProps) {
|
|
if (!fileData.toc) {
|
|
return null
|
|
}
|
|
|
|
return <details class="toc" open>
|
|
<summary><h3>Table of Contents</h3></summary>
|
|
<ul>
|
|
{fileData.toc.map(tocEntry => <li key={tocEntry.slug} class={`depth-${tocEntry.depth}`}>
|
|
<a href={`#${tocEntry.slug}`}>{tocEntry.text}</a>
|
|
</li>)}
|
|
</ul>
|
|
</details>
|
|
}
|
|
|
|
TableOfContents.css = style
|