From 3a583c32bd30b6230ea03815ebea9f8c50db229c Mon Sep 17 00:00:00 2001 From: Eltrac Date: Thu, 19 Dec 2024 15:53:18 +0800 Subject: feat(theme): add tocbot for table of content --- layouts/partials/scripts.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'layouts/partials/scripts.html') 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(); }); -- cgit v1.2.3