custom.js 521 B

123456789101112131415161718
  1. (() => {
  2. const uri = new URL(location.href);
  3. document.querySelector('header nav h2').addEventListener('click', function () {
  4. this.parentNode.querySelector('ul').classList.toggle('show');
  5. }, false);
  6. document.querySelectorAll("main h2[id]").forEach((header) => {
  7. uri.hash = header.id;
  8. let link = document.createElement("a");
  9. link.className = "header-permalink";
  10. link.title = "Permalink";
  11. link.href = uri.toString();
  12. link.innerHTML = "¶";
  13. header.appendChild(link);
  14. });
  15. })();