:lock: Secure and accessible dark theme static website generator for Hugo 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 983B

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. (function(l,o,a,d,e,r){e=o.createElement(a),r=o.getElementsByTagName(a)[0];e.async=1;e.src=d;r.parentNode.insertBefore(e,r)})(window,document,'script','{{ "/js/smoothscroll.js" | relURL | safeJS }}');
  11. el.onclick = null;
  12. };
  13. document.querySelectorAll('#TableOfContents a').forEach(link => {
  14. link.addEventListener('click', (evt) => {
  15. evt.preventDefault();
  16. const selector = link.href.slice(link.href.indexOf('#'));
  17. document.querySelector(
  18. selector
  19. ).scrollIntoView({ behavior: 'smooth' });
  20. window.history.pushState({}, "", selector);
  21. });
  22. });
  23. })(window, document);
  24. </script>
  25. {{ end }}