mirror of
https://github.com/alrayyes/wiki.git
synced 2025-06-08 06:36:40 +00:00
toc
This commit is contained in:
parent
3a29f4c86e
commit
b8c011410d
21 changed files with 233 additions and 66 deletions
quartz/components
24
quartz/components/TableOfContents.tsx
Normal file
24
quartz/components/TableOfContents.tsx
Normal file
|
@ -0,0 +1,24 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue