use first line as document title

This commit is contained in:
Joshua Seigler 2025-05-02 09:18:02 -04:00
parent a67b6032c5
commit 160fc55f12
3 changed files with 19 additions and 4 deletions

9
.editorconfig Normal file
View file

@ -0,0 +1,9 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

View file

@ -1,2 +0,0 @@
language = "html"
run = ""

View file

@ -1317,6 +1317,14 @@ return je}()
;"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs);
</script>
<script>
function updateCountAndTitle() {
urlLengthDisplay.innerHTML = (''+window.location).length;
if (main.firstChild && main.firstChild.innerText) {
document.title = main.firstChild.innerText.split('\n')[0];
} else {
document.title = "MarkLink document-in-a-URL";
}
}
var md = new window.markdownit({
linkify:true,
typographer: true,
@ -1337,12 +1345,12 @@ return je}()
var text = LZString.decompressFromEncodedURIComponent(window.location.hash.substr(1));
raw.value = text;
main.innerHTML = md.render(text);
urlLengthDisplay.innerHTML = (''+window.location).length;
updateCountAndTitle();
}
raw.oninput = function() {
history.replaceState(null, null, "#"+LZString.compressToEncodedURIComponent(raw.value));
main.innerHTML = md.render(raw.value);
urlLengthDisplay.innerHTML = (''+window.location).length;
updateCountAndTitle();
}
</script>
</body>