diff options
Diffstat (limited to 'services/nuldoc/nuldoc-src/components/TableOfContents.ts')
| -rw-r--r-- | services/nuldoc/nuldoc-src/components/TableOfContents.ts | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/services/nuldoc/nuldoc-src/components/TableOfContents.ts b/services/nuldoc/nuldoc-src/components/TableOfContents.ts deleted file mode 100644 index 1eb79e98..00000000 --- a/services/nuldoc/nuldoc-src/components/TableOfContents.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { TocEntry, TocRoot } from "../markdown/document.ts"; -import { a, Element, h2, li, nav, ul } from "../dom.ts"; - -type Props = { - toc: TocRoot; -}; - -export default function TableOfContents({ toc }: Props): Element { - return nav( - { class: "toc" }, - h2({}, "目次"), - ul( - {}, - ...toc.entries.map((entry) => TocEntryComponent({ entry })), - ), - ); -} - -function TocEntryComponent({ entry }: { entry: TocEntry }): Element { - return li( - {}, - a({ href: `#${entry.id}` }, entry.text), - entry.children.length > 0 - ? ul( - {}, - ...entry.children.map((child) => TocEntryComponent({ entry: child })), - ) - : null, - ); -} |
