diff options
| author | Reorx <novoreorx@gmail.com> | 2022-04-12 23:24:32 +0800 |
|---|---|---|
| committer | Reorx <novoreorx@gmail.com> | 2022-04-12 23:24:32 +0800 |
| commit | 2d9e5a2e38d52a5c88916d5527fca8ae05c3fe7f (patch) | |
| tree | 88bc1efba3e53404658881e4da56d8dbbf86306d | |
| parent | ff2dc3c45d11c5aad74931df686f9eb3cb72cedc (diff) | |
fix toc script run scope
| -rw-r--r-- | layouts/partials/footer.html | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 4e348be..ab4496c 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -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'; |
