Improve sections

This commit is contained in:
2026-04-28 17:43:20 +02:00
parent 1f7cfd637a
commit 73a8b4f78f
6 changed files with 59 additions and 2 deletions
+11
View File
@@ -0,0 +1,11 @@
(function () {
document.querySelectorAll('.content h1, .content h2, .content h3, .content h4, .content h5, .content h6').forEach(function (h) {
if (!h.id) return;
var a = document.createElement('a');
a.href = '#' + h.id;
a.className = 'heading-anchor';
a.setAttribute('aria-label', 'Link to this section');
a.textContent = '§';
h.insertBefore(a, h.firstChild);
});
}());
+1
View File
@@ -81,6 +81,7 @@
{{end}}
{{if or .Content .SpecialContent}}
<script src="/_/content.js"></script>
<script src="/_/anchors.js"></script>
<script src="/_/toc.js"></script>
{{end}}
{{if .Content}}
+9
View File
@@ -234,6 +234,15 @@ main {
max-width: 100%;
}
.heading-anchor {
color: var(--text-muted);
margin-right: 0.4em;
font-weight: normal;
}
.heading-anchor:hover {
color: var(--primary-hover);
}
/* === File listing === */
.listing {
border: 1px solid var(--secondary);
+1 -1
View File
@@ -21,7 +21,7 @@
var a = document.createElement("a");
a.href = "#" + h.id;
var clone = h.cloneNode(true);
clone.querySelectorAll(".btn, .muted").forEach(function (el) { el.remove(); });
clone.querySelectorAll(".btn, .muted, .heading-anchor").forEach(function (el) { el.remove(); });
a.textContent = clone.textContent.trim();
li.appendChild(a);
list.appendChild(li);