Add theme color support

This commit is contained in:
Nicholas Jitkoff 2022-06-10 22:29:43 -07:00
parent 04fa9fec3e
commit 3aafb96af3
2 changed files with 6 additions and 0 deletions

View file

@ -4,6 +4,7 @@
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, viewport-fit=cover">
<meta name="description" content="itty bitty things can be conveyed in a link.">
<meta id="themeColor" name="theme-color" content="#ebeff9">
<link id="favicon" rel="icon" href='/favicon.svg'>
<link rel="stylesheet" href="/index.css">
<script src="/js/lzma/lzma-d-min.js"></script>

View file

@ -25,6 +25,10 @@
// </div>`
}
function setThemeColor(color) {
document.getElementById("themeColor").content = color;
}
function setFavicon(favicon) {
document.getElementById("favicon").href = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"><text y=".9em">'+ favicon + '</text></svg>'
}
@ -48,6 +52,7 @@
console.debug("Message:", e.origin, e.data)
if (e.data.title) document.title = e.data.title;
if (e.data.favicon) setFavicon(e.data.favicon);
if (e.data.themeColor) setThemeColor(e.data.themeColor);
if (e.data.updateURL) {
let path = ["/" + e.data.title.replace(/\s/g, "-")];
if (e.data.description) path.push("d/" + encodeURIComponent(e.data.description));