what would be the correct way to do this? ( i figure there is a more astro way i am not able to do?)
---
import type { Props } from '@astrojs/starlight/props';
import Default from '@astrojs/starlight/components/Head.astro';
---
<script>
// const input = document.documentElement.dataset.theme;
const input = document.documentElement.getAttribute('data-theme');
console.log(input);
var test = `./public/favicon-${input}.svg`;
console.log(input, test);
// must use the html base, mine is /astro-starlight/ , and not the file path ./public/ since the latter only works in dev mode
if (input == 'light') {
var test = "/astro-starlight/favicon-primary-light.svg";
}
else if (input == 'dark') {
var test = "/astro-starlight/favicon-primary-dark.svg";
}
else {
var test = "/astro-starlight/favicon-blue.svg";
}
console.log(input, test);
var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
console.log(link);
link.id = 'favicon';
(link as HTMLLinkElement).type = 'image/png';
(link as HTMLLinkElement).rel = 'shortcut icon';
(link as HTMLLinkElement).href = `${test}`;
document.getElementsByTagName('head')[0].appendChild(link);
console.log(link);
</script>
<Default {...Astro.props} ></Default>