@@ -49,7 +49,7 @@
%TOC%
diff --git a/moonbit-tour/src/main.ts b/moonbit-tour/src/main.ts
index e401e61d..935f872f 100644
--- a/moonbit-tour/src/main.ts
+++ b/moonbit-tour/src/main.ts
@@ -1,6 +1,7 @@
import * as moonbitMode from "@moonbit/moonpad-monaco";
import * as monaco from "monaco-editor-core";
import "./style.css";
+import "./toc";
const moon = moonbitMode.init({
onigWasmUrl: new URL("./onig.wasm", import.meta.url).toString(),
@@ -18,12 +19,6 @@ self.MonacoEnvironment = {
},
};
-const tocButton = document.getElementById("toc-button")!;
-const toc = document.getElementById("toc")!;
-tocButton.onclick = () => {
- toc.classList.toggle("md:block");
-};
-
const sunSvg = `
diff --git a/moonbit-tour/src/toc.ts b/moonbit-tour/src/toc.ts
new file mode 100644
index 00000000..c49f3346
--- /dev/null
+++ b/moonbit-tour/src/toc.ts
@@ -0,0 +1,17 @@
+function tocChapter(div: HTMLDivElement) {
+ const title = div.querySelector
(".toc-chapter-title")!;
+ const sections = div.querySelector(".toc-sections")!;
+ title.onclick = () => {
+ sections.classList.toggle("hidden");
+ };
+}
+
+const tocButton = document.getElementById("toc-button")!;
+const toc = document.getElementById("toc")!;
+tocButton.onclick = () => {
+ toc.classList.toggle("hidden");
+};
+
+for (const div of document.querySelectorAll(".toc-chapter")) {
+ tocChapter(div);
+}
diff --git a/moonbit-tour/tailwind.config.js b/moonbit-tour/tailwind.config.js
index 9d01dbd3..4dbb7251 100644
--- a/moonbit-tour/tailwind.config.js
+++ b/moonbit-tour/tailwind.config.js
@@ -1,7 +1,7 @@
/** @type {import('tailwindcss').Config} */
export default {
darkMode: "class",
- content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}", "./dev/*.ts"],
+ content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}", "./build/*.ts"],
theme: {
fontFamily: {
sans: [
@@ -37,27 +37,27 @@ export default {
typography: {
DEFAULT: {
css: {
- 'code::before': {
+ "code::before": {
content: '""',
},
- 'code::after': {
+ "code::after": {
content: '""',
},
code: {
- backgroundColor: '#f7fafc',
- borderRadius: '0.25rem',
- padding: '0.125rem 0.25rem',
- border: '1px solid #e9e9e9',
- color: '#222',
+ backgroundColor: "#f7fafc",
+ borderRadius: "0.25rem",
+ padding: "0.125rem 0.25rem",
+ border: "1px solid #e9e9e9",
+ color: "#222",
},
},
},
invert: {
css: {
code: {
- backgroundColor: '#1f2937',
- border: '1px solid #374151',
- color: '#d1d5db',
+ backgroundColor: "#1f2937",
+ border: "1px solid #374151",
+ color: "#d1d5db",
},
},
},