fix toc script run scope

This commit is contained in:
Reorx 2022-04-12 23:24:32 +08:00
parent ff2dc3c45d
commit 2d9e5a2e38
1 changed files with 4 additions and 1 deletions

View File

@ -138,9 +138,12 @@
</script>
{{- end }}
{{- if (and (eq .Kind "page") (.Param "ShowToc") (.Param "TocSide")) }}
{{- if (and (eq .Kind "page") (.Content) (.Param "ShowToc") (.Param "TocSide")) }}
<script>
window.addEventListener('DOMContentLoaded', function (event) {
if (!document.querySelector('.toc')) {
return;
}
const headings = document.querySelectorAll('h1[id],h2[id],h3[id],h4[id],h5[id]');
const activeClass = 'active';