Fix JavaScript null error on home and splash layouts (#4939)

This commit is contained in:
Archer
2024-09-26 13:39:03 +08:00
committed by GitHub
parent a3e2b33c5e
commit 5fd703674b
3 changed files with 21 additions and 17 deletions

View File

@ -123,8 +123,11 @@ $(document).ready(function () {
}); });
// Add anchors for headings // Add anchors for headings
document (function () {
.querySelector(".page__content") var pageContentElement = document.querySelector(".page__content");
if (!pageContentElement) return;
pageContentElement
.querySelectorAll("h1, h2, h3, h4, h5, h6") .querySelectorAll("h1, h2, h3, h4, h5, h6")
.forEach(function (element) { .forEach(function (element) {
var id = element.getAttribute("id"); var id = element.getAttribute("id");
@ -138,6 +141,7 @@ $(document).ready(function () {
element.appendChild(anchor); element.appendChild(anchor);
} }
}); });
})();
// Add copy button for <pre> blocks // Add copy button for <pre> blocks
var copyText = function (text) { var copyText = function (text) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long