summaryrefslogtreecommitdiff
path: root/layouts/_default/single.html
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-05-16 15:03:14 +0800
committerEltrac <hi@guhub.cn>2025-05-16 15:03:14 +0800
commit4b4629edb733d5ebd6485755fd2f63b0457f62c8 (patch)
treeb772561bab2cd21aa6a5acaea8af65999b83f78e /layouts/_default/single.html
parent2e1c4f08ac54232787d15d0175f0e99e2a701f78 (diff)
perf: replace tocbot with statically generated toc
Generate TOC with Hugo's built-in {{ .TableOfContents }} and add minimal script to implement collapsible list and active styles. Encapsulate TOC as a component where all JavaSript and CSS is in one place with HTML. Configure markup.
Diffstat (limited to 'layouts/_default/single.html')
-rw-r--r--layouts/_default/single.html14
1 files changed, 0 insertions, 14 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index bfe80ad5..d23ceed4 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -7,24 +7,10 @@
<!-- Content -->
<div id="post-content" class="post-content markdown-body"
style="view-transition-name: post-content-{{ .File.UniqueID }}">
- {{ if .Params.toc }}
- <div id="toc-container"><div id="toc"></div></div>
- {{ end }}
{{ .Site.Params.postHeaderContent | safeHTML }}
{{ .Content }}
</div>
- <script src="/js/tocbot.min.js"></script>
- <script>
- tocbot.init({
- tocSelector: '#toc',
- contentSelector: '#post-content',
- headingSelector: 'h2, h3:not(blockquote > h3)',
- hasInnerContainers: true,
- scrollSmoothOffset: -30
- });
- </script>
-
</article>
{{ partial "footer.html" . }}
{{ end }}