-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b61c242
commit 8fd8f7f
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
const img = document.querySelector(".theme-toggle-image"); | ||
|
||
if (!img) return; // Exit if no image is found | ||
|
||
// Function to update the image based on the current theme | ||
function updateImage() { | ||
const theme = document.body.getAttribute("data-md-color-scheme"); | ||
img.src = theme === "slate" ? "images/NPLinker_standard_white.svg" : "images/NPLinker_standard_black.svg"; | ||
} | ||
|
||
// Initial update | ||
updateImage(); | ||
|
||
// Observe changes to the `data-md-color-scheme` attribute | ||
const observer = new MutationObserver(updateImage); | ||
observer.observe(document.body, { | ||
attributes: true, | ||
attributeFilter: ["data-md-color-scheme"], // Monitor changes to the theme attribute | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters