more robust title search
This commit is contained in:
parent
112c0e6f08
commit
7491889ecc
@ -23,9 +23,13 @@
|
|||||||
const options = { ...marked.defaults, breaks: true };
|
const options = { ...marked.defaults, breaks: true };
|
||||||
|
|
||||||
function setTitle() {
|
function setTitle() {
|
||||||
const res = ref.querySelector('h1');
|
const tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
||||||
if (res) {
|
for (const tag of tags) {
|
||||||
document.title = res.innerText;
|
const element: HTMLHeadingElement | null = ref.querySelector(tag);
|
||||||
|
if (element && element.innerText.trim().length > 0) {
|
||||||
|
document.title = element.innerText.trim();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user