Skip to content

Commit 88e21d6

Browse files
committed
fix: h1 may be null
1 parent f2b1af9 commit 88e21d6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

layouts/layout.dark.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,8 @@
846846
});
847847

848848
// automatically set title
849-
let h1 = document.querySelector("h1");
850-
if (document.title === '') {
849+
const h1 = document.querySelector("h1");
850+
if (!document.title && h1 && h1.textContent) {
851851
document.title = h1.textContent;
852852
}
853853
</script>

layouts/layout.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,8 @@
717717
});
718718

719719
// automatically set title
720-
let h1 = document.querySelector("h1");
721-
if (document.title === '') {
720+
const h1 = document.querySelector("h1");
721+
if (!document.title && h1 && h1.textContent) {
722722
document.title = h1.textContent;
723723
}
724724
</script>

0 commit comments

Comments
 (0)