mirror of
https://git.kittycat.homes/zoe/hugo-battheme.git
synced 2024-08-15 03:25:18 +00:00
clickable headers
This commit is contained in:
parent
2e52a4843f
commit
2c56b25d22
10 changed files with 207 additions and 108 deletions
13
static/js/headings.js
Normal file
13
static/js/headings.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
(function addHeadingLinks() {
|
||||
var article = document.getElementById("content");
|
||||
var headings = article.querySelectorAll("h1, h2, h3, h4, h5, h6");
|
||||
headings.forEach(function (heading) {
|
||||
if (heading.id) {
|
||||
var a = document.createElement("a");
|
||||
a.innerHTML = heading.innerHTML;
|
||||
a.href = "#" + heading.id;
|
||||
heading.innerHTML = "";
|
||||
heading.appendChild(a);
|
||||
}
|
||||
});
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue