1 | function createAnchors() { |
2 | let headers = document.querySelectorAll("#links, #comments, .blog-content h1, .content-body h2, .content-body h3, .content-body h4, .content-body h5, .content-body h6"); |
3 | for (header of headers) { |
4 | let id = header.id; |
5 | if (id == "") continue; |
6 | header.classList.add("header") |
7 | let anchor = document.createElement("a") |
8 | anchor.classList.value = "anchor" |
9 | anchor.href = "#" + id |
10 | let svg = document.createElement("img") |
11 | svg.src = "/static/svg/link.svg" |
12 | svg.classList.value = "svg icon" |
13 | anchor.appendChild(svg) |
14 | header.appendChild(anchor) |
15 | } |
16 | } |
17 |
|
18 | document.addEventListener('DOMContentLoaded', createAnchors); |
19 |
|