Hugo Dark Theme Site Generator https://after-dark.habd.as
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

toc-maybe.html 852B

12345678910111213141516171819202122232425
  1. {{ if and (isset .Params "toc") .Params.toc }}
  2. <details>
  3. <summary>Table of Contents</summary>
  4. {{ .TableOfContents }}
  5. </details>
  6. <script>
  7. (function (window, document, undefined) {
  8. const el = document.querySelector('details summary');
  9. el.onclick = () => {
  10. fetchInject([{{ "/js/smoothscroll.js" | relURL }}]);
  11. el.onclick = null;
  12. document.querySelectorAll('#TableOfContents a').forEach(link => {
  13. link.addEventListener('click', evt => {
  14. evt.preventDefault();
  15. const selector = link.href.slice(link.href.indexOf('#'));
  16. document.querySelector(
  17. selector
  18. ).scrollIntoView({ behavior: 'smooth' });
  19. window.history.pushState({}, "", selector);
  20. });
  21. });
  22. };
  23. })(window, document);
  24. </script>
  25. {{ end }}