hugo-theme-minima/minima.js
2023-03-15 16:22:56 +00:00

1 line
884 B
JavaScript

(()=>{var h="giscus",a="🌝",r="🌚",c="light",d="dark",s,n,i;function m(e){s||(s=document.getElementById(e)),s.innerHTML=localStorage.theme===c?a:r,s.addEventListener("click",f)}function f(){let e=localStorage.getItem("theme"),t=e===c?d:c;switch(g(e,t),h){case"utterances":_(`github-${t}`);break;case"giscus":p(t);break;default:}}function g(e,t){let{classList:o}=document.documentElement,l=t===c?a:r;o.remove(e),o.add(t),localStorage.setItem("theme",t),s.innerHTML=l}function _(e){n=n||document.querySelector("iframe.utterances-frame"),!!n&&n.contentWindow.postMessage({type:"set-theme",theme:e},"https://utteranc.es")}function p(e){i=i||document.querySelector("iframe.giscus-frame"),!!i&&i.contentWindow.postMessage({giscus:{setConfig:{theme:e}}},"https://giscus.app")}function u(){"true"==="false"&&(document.documentElement.style="user-select:none")}m("theme-switch");u();})();