Evaluate image theme on page load as well

This commit is contained in:
saberzero1 2024-09-23 20:12:50 +02:00
parent 6867034ec9
commit 0011e85e75
No known key found for this signature in database
GPG Key ID: 41AEE99107640F10

View File

@ -37,7 +37,8 @@ export function getUserPreferredColorScheme() {
// Have SVG images in the article adhere to the correct color scheme. // Have SVG images in the article adhere to the correct color scheme.
document.addEventListener("nav", (e) => { document.addEventListener("nav", (e) => {
let theme = localStorage.getItem("theme") ?? getUserPreferredColorScheme() let theme: "dark" | "light" =
(localStorage.getItem("theme") as "dark" | "light" | null) ?? getUserPreferredColorScheme()
Object.values(document.getElementsByTagName("article")[0].getElementsByTagName("a")).forEach( Object.values(document.getElementsByTagName("article")[0].getElementsByTagName("a")).forEach(
(a) => { (a) => {
if (a.href.endsWith(".excalidraw")) { if (a.href.endsWith(".excalidraw")) {
@ -47,6 +48,7 @@ document.addEventListener("nav", (e) => {
} }
}, },
) )
renderThemedLinks(theme)
}) })
export function removeAllChildren(node: HTMLElement) { export function removeAllChildren(node: HTMLElement) {