@@ -44,16 +42,22 @@
-
+
-
+
- {{ countwords .Content }} Words
+
+ {{ countwords .Content }} Words
@@ -76,7 +80,7 @@
-
+
{{- .Content -}}
@@ -88,66 +92,5 @@
-
+
+
\ No newline at end of file
diff --git a/static/css/toc.css b/static/css/toc.css
new file mode 100644
index 0000000..780117d
--- /dev/null
+++ b/static/css/toc.css
@@ -0,0 +1,4 @@
+.toc-item {
+ font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
+ line-height: 1.5;
+}
\ No newline at end of file
diff --git a/static/js/toc.js b/static/js/toc.js
index e69de29..7ffb525 100644
--- a/static/js/toc.js
+++ b/static/js/toc.js
@@ -0,0 +1,43 @@
+const details = document.querySelector("#toc-details");
+
+function clickToc() {
+ switch (details.style.display) {
+ case 'none':
+ details.style.display = 'block';
+ setTimeout(() =>
+ document.body.addEventListener('click', closeToc), 1);
+ break;
+ case 'block':
+ details.style.display = 'none';
+ break;
+ }
+}
+
+function openToc() {
+ details.style.display = 'block';
+}
+
+function closeToc() {
+ details.style.display = 'none';
+ document.body.removeEventListener('click', closeToc);
+}
+
+function getToc() {
+ const hs = document.querySelector('.markdown-body').querySelectorAll('h1, h2, h3, h4, h5, h6');
+ const toc_list = document.querySelector("#toc-list");
+ for (const h of hs) {
+ const size = Number(h.tagName.toLowerCase().replace('h', ''));
+ const a = document.createElement('a');
+ a.classList.add("filter-item", "SelectMenu-item", "ws-normal", "wb-break-word", "line-clamp-2", "py-1", "toc-item");
+ a.href = `#${h.id}`;
+ a.innerText = h.innerHTML;
+ a.style.paddingLeft = `${size * 12}px`;
+ toc_list.appendChild(a);
+ }
+}
+
+
+// TODO: highlight on scroll
+(() => {
+ getToc();
+})();