Fix making header linkable
This commit is contained in:
parent
ef7d0fe108
commit
0d7267f52a
2 changed files with 9 additions and 6 deletions
|
@ -28,7 +28,7 @@
|
|||
<h1>{{ .Page.Title }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="post-content">
|
||||
<div class="post-content" id="post-content">
|
||||
{{ .Page.Content }}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -25,11 +25,14 @@ var isMobile = false, isTablet = false, isLaptop = false;
|
|||
element.innerHTML = `<a href="#${element.id}" class="header-anchor">${element.innerHTML}<sup><i class="fas fa-link"></i></sup></a>`;
|
||||
}
|
||||
|
||||
var headerTypes = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
||||
for (var i = 0; i < headerTypes.length; i++) {
|
||||
var headers = document.querySelectorAll(headerTypes[i]);
|
||||
if (headers) {
|
||||
headers.forEach(addAnchor);
|
||||
var postContent = document.getElementById("post-content");
|
||||
if (postContent != null) {
|
||||
var headerTypes = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
||||
for (var i = 0; i < headerTypes.length; i++) {
|
||||
var headers = postContent.querySelectorAll(headerTypes[i]);
|
||||
if (headers) {
|
||||
headers.forEach(addAnchor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue