summaryrefslogtreecommitdiff
path: root/layouts/partials/scripts.html
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2024-12-19 15:53:18 +0800
committerEltrac <hi@guhub.cn>2024-12-19 15:53:18 +0800
commit3a583c32bd30b6230ea03815ebea9f8c50db229c (patch)
tree776a488abc41327c375c611d4bd4556d11b61532 /layouts/partials/scripts.html
parentd5e989e878e2f1a4dc9814381a589e86b38769c5 (diff)
feat(theme): add tocbot for table of content
Diffstat (limited to 'layouts/partials/scripts.html')
-rw-r--r--layouts/partials/scripts.html15
1 files changed, 15 insertions, 0 deletions
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
index 60ef902c..89be5e8d 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/partials/scripts.html
@@ -33,11 +33,26 @@ lazyLoadInstance.update();
/* === Fancybox === */
Fancybox.bind("[data-fancybox]");
+/* === tocbot === */
+function loadToc() {
+ tocbot.init({
+ tocSelector: '#toc',
+ // Where to grab the headings to build the table of contents.
+ contentSelector: '#post-content',
+ // Which headings to grab inside of the contentSelector element.
+ headingSelector: 'h2, h3',
+ // For headings inside relative or absolute positioned containers within content.
+ hasInnerContainers: true,
+ });
+}
+loadToc();
+
/* === swup === */
const swup = new Swup();
swup.hooks.on('page:view', () => {
loadWalineComment();
lazyLoadInstance.update();
Fancybox.bind("[data-fancybox]");
+ loadToc();
});
</script>