diff --git a/docs/assets/icon.svg b/docs/assets/icon.svg index da120aa..9ab1fac 100644 --- a/docs/assets/icon.svg +++ b/docs/assets/icon.svg @@ -2,7 +2,7 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/scripts/favicon.js b/docs/scripts/favicon.js new file mode 100644 index 0000000..5b4405a --- /dev/null +++ b/docs/scripts/favicon.js @@ -0,0 +1,17 @@ +function setFavicon(dark) { + console.log({ dark }); + + const favicon = document.querySelector('link[rel="icon"]'); + const name = dark ? "icon_dark" : "icon"; + favicon.href = `/assets/${name}.svg`; +} + +document$.subscribe(() => { + const query = window.matchMedia("(prefers-color-scheme: dark)"); + + setFavicon(query.matches); + + query.addEventListener("change", (event) => { + setFavicon(event.matches); + }); +}); diff --git a/mkdocs.yml b/mkdocs.yml index 1fe5662..be9a1e5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -68,3 +68,5 @@ plugins: extra_css: - styles/extra.css +extra_javascript: + - scripts/favicon.js