fix toc script run scope
This commit is contained in:
parent
ff2dc3c45d
commit
2d9e5a2e38
|
@ -138,9 +138,12 @@
|
||||||
</script>
|
</script>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- if (and (eq .Kind "page") (.Param "ShowToc") (.Param "TocSide")) }}
|
{{- if (and (eq .Kind "page") (.Content) (.Param "ShowToc") (.Param "TocSide")) }}
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('DOMContentLoaded', function (event) {
|
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 headings = document.querySelectorAll('h1[id],h2[id],h3[id],h4[id],h5[id]');
|
||||||
const activeClass = 'active';
|
const activeClass = 'active';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue