Clean toc heading link

The heading link only show up when we hovering it
This commit is contained in:
Dan 2025-03-17 20:00:37 +07:00
commit fda3af37f4
2 changed files with 9 additions and 1 deletions

View file

@ -49,4 +49,12 @@ summary {
border:none;
margin-left: 5px;
box-shadow:none;
}
.toc-link a {
display:none;
}
.toc-link:hover a{
display:inline-block;
}

View file

@ -39,7 +39,7 @@ function generateTOC (id) {
anchor.setAttribute('href', '#' + heading.textContent.replace(/\s+/g, '-').toLowerCase() + id);
anchor.setAttribute('class', 'anchor');
anchor.setAttribute('aria-label', heading.textContent);
anchor.innerHTML = '<svg fill="currentColor" class="toc-icon" viewBox="0 0 24 24" height="20" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"></path><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z"></path></svg>';
anchor.innerHTML = '<svg fill="currentColor" class="toc-icon" viewBox="0 0 24 24" height="18" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"></path><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z"></path></svg>';
var link = documentRef.createElement('a');
link.setAttribute('href', '#' + heading.textContent.replace(/\s+/g, '-').toLowerCase() + id);