Fix JavaScript null error on home and splash layouts (#4939)
This commit is contained in:
@ -123,21 +123,25 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add anchors for headings
|
// Add anchors for headings
|
||||||
document
|
(function () {
|
||||||
.querySelector(".page__content")
|
var pageContentElement = document.querySelector(".page__content");
|
||||||
.querySelectorAll("h1, h2, h3, h4, h5, h6")
|
if (!pageContentElement) return;
|
||||||
.forEach(function (element) {
|
|
||||||
var id = element.getAttribute("id");
|
pageContentElement
|
||||||
if (id) {
|
.querySelectorAll("h1, h2, h3, h4, h5, h6")
|
||||||
var anchor = document.createElement("a");
|
.forEach(function (element) {
|
||||||
anchor.className = "header-link";
|
var id = element.getAttribute("id");
|
||||||
anchor.href = "#" + id;
|
if (id) {
|
||||||
anchor.innerHTML =
|
var anchor = document.createElement("a");
|
||||||
'<span class="sr-only">Permalink</span><i class="fas fa-link"></i>';
|
anchor.className = "header-link";
|
||||||
anchor.title = "Permalink";
|
anchor.href = "#" + id;
|
||||||
element.appendChild(anchor);
|
anchor.innerHTML =
|
||||||
}
|
'<span class="sr-only">Permalink</span><i class="fas fa-link"></i>';
|
||||||
});
|
anchor.title = "Permalink";
|
||||||
|
element.appendChild(anchor);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
// Add copy button for <pre> blocks
|
// Add copy button for <pre> blocks
|
||||||
var copyText = function (text) {
|
var copyText = function (text) {
|
||||||
|
2
assets/js/main.min.js
vendored
2
assets/js/main.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user