From 57315c52be96d2a2c013f0cfb0de5429980e301a Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sun, 2 Nov 2025 17:49:34 +0900
Subject: refactor(blog): rename directory, services/{blog => nuldoc}/

---
 .../nuldoc-src/components/TableOfContents.tsx      | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 services/nuldoc/nuldoc-src/components/TableOfContents.tsx

(limited to 'services/nuldoc/nuldoc-src/components/TableOfContents.tsx')

diff --git a/services/nuldoc/nuldoc-src/components/TableOfContents.tsx b/services/nuldoc/nuldoc-src/components/TableOfContents.tsx
new file mode 100644
index 0000000..29907d0
--- /dev/null
+++ b/services/nuldoc/nuldoc-src/components/TableOfContents.tsx
@@ -0,0 +1,33 @@
+import { TocEntry, TocRoot } from "../djot/document.ts";
+
+type Props = {
+  toc: TocRoot;
+};
+
+export default function TableOfContents({ toc }: Props) {
+  return (
+    <nav className="toc">
+      <h2>目次</h2>
+      <ul>
+        {toc.entries.map((entry, index) => (
+          <TocEntryComponent key={String(index)} entry={entry} />
+        ))}
+      </ul>
+    </nav>
+  );
+}
+
+function TocEntryComponent({ entry }: { entry: TocEntry }) {
+  return (
+    <li>
+      <a href={`#${entry.id}`}>{entry.text}</a>
+      {entry.children.length > 0 && (
+        <ul>
+          {entry.children.map((child, index) => (
+            <TocEntryComponent key={String(index)} entry={child} />
+          ))}
+        </ul>
+      )}
+    </li>
+  );
+}
-- 
cgit v1.2.3-70-g09d2

