feat: refactor code to require refetching the theme whenever a new version releases
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful

This commit is contained in:
Twig 2025-07-16 05:30:11 +02:00
parent e87edbc967
commit 8a172db3f4
No known key found for this signature in database
3 changed files with 37 additions and 27 deletions

View file

@ -0,0 +1,27 @@
let themeLinkElement: HTMLLinkElement | null;
export default function loadPreferredTheme() {
const runtimeConfig = useRuntimeConfig()
const baseURL = runtimeConfig.app.baseURL;
const currentTheme = settingsLoad().selectedThemeId ?? "dark"
if (themeLinkElement && themeLinkElement.getAttribute('href') === `${baseURL}themes/${currentTheme}.css`) {
return;
}
if (themeLinkElement) {
themeLinkElement.href = `${baseURL}themes/${currentTheme}.css`;
} else {
// create the theme link if one doesn't already exist
useHead({
link: [{
id: "main-theme",
rel: "stylesheet",
// this should preferrably use version hash, but that's not implemented yet
href: `${baseURL}themes/${currentTheme}.css?v=${runtimeConfig.public.buildTimeString}`
}]
})
themeLinkElement = document.getElementById('main-theme') as HTMLLinkElement;
}
}