Browse Source

📝 Fix Typer logo light/dark theme for GitHub and MkDocs

pull/14983/head
rxxbyy 4 months ago
parent
commit
022e666c3f
  1. 21
      docs/en/docs/js/custom.js

21
docs/en/docs/js/custom.js

@ -175,17 +175,28 @@ function handleSponsorImages() {
}
function setupThemeImages() {
new MutationObserver(() => {
const updateImages = () => {
const scheme = document.body.getAttribute("data-md-color-scheme");
const isDark = scheme === "slate";
document.querySelectorAll("picture[data-light-src][data-dark-src]").forEach((picture) => {
const src = isDark ? picture.dataset.darkSrc : picture.dataset.lightSrc;
const src = (isDark ? picture.dataset.darkSrc : picture.dataset.lightSrc);
const source = picture.querySelector("source");
const img = picture.querySelector("img");
if (source) source.srcset = src;
if (img) img.src = src;
if (source) {
source.srcset = src;
}
if (img) {
img.src = src;
}
});
}).observe(document.body, { attributes: true, attributeFilter: ["data-md-color-scheme"] });
}
new MutationObserver(updateImages).observe(document.body, {
attributes: true,
attributeFilter: ["data-md-color-scheme"],
});
updateImages();
}
async function main() {

Loading…
Cancel
Save