File: custom.js

package info (click to toggle)
php-league-commonmark 2.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,260 kB
  • sloc: php: 20,378; xml: 1,988; ruby: 45; makefile: 21; javascript: 15
file content (18 lines) | stat: -rw-r--r-- 521 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(() => {

  const uri = new URL(location.href);

  document.querySelector('header nav h2').addEventListener('click', function () {
    this.parentNode.querySelector('ul').classList.toggle('show');
  }, false);

  document.querySelectorAll("main h2[id]").forEach((header) => {
    uri.hash = header.id;
    let link = document.createElement("a");
    link.className = "header-permalink";
    link.title = "Permalink";
    link.href = uri.toString();
    link.innerHTML = "¶";
    header.appendChild(link);
  });
})();