hugo-theme-minima/minima.1667902099.js
2022-11-08 10:08:20 +00:00

4 lines
1.5 KiB
JavaScript

(()=>{var r="🌝",l="🌚",h="utterances",i="light",f="dark",a=document.getElementById("theme-switcher");a.innerHTML=localStorage.theme===i?r:l;a.addEventListener("click",function(){let e=localStorage.theme,t=e===i?f:i;p(e,t),h==="utterances"&&g(`github-${t}`)});function p(e,t){let{classList:c}=document.documentElement,n=t===i?r:l;c.remove(e),c.add(t),localStorage.theme=t,a.innerHTML=n}var S=".utterances-frame",o;function g(e){o||(o=document.querySelector(S)),o.contentWindow.postMessage({type:"set-theme",theme:e},"https://utteranc.es")}document.querySelectorAll(".md ul").forEach(e=>{/<li><input .+>.+<\/li>/.test(e.innerHTML)&&e.classList.add("ul-checkbox")});var k="true";k==="false"&&(document.documentElement.style="user-select:none");var w=document.getElementById("friends"),y="3",b="[]",v=b.replace(/^\[|\]$/g,"").split(" ");v.forEach(e=>fetch(e).then(t=>t.text()).then(t=>E(t)));function E(e){e=e.trim().replace(/\n/g,"");let t=e.matchAll(/<(item|entry)>.*?<\/(item|entry)>/g),c=+y||2;for(;c;){let n=t.next();if(n.done)break;let m=n.value[0].match(/(?<=<title>).*(?=<\/title>)/)[0],d=n.value[0].match(/(?<=<(link|id)>).*(?=<\/(link|id)>)/)[0],u=n.value[0].match(/(?<=<(pubDate|updated)>).*(?=<\/(pubDate|updated)>)/)[0],s=document.createElement("div");s.className="flex justify-between",s.innerHTML=L(d,m,u),w.appendChild(s),c--}}function x(e){return new Date(e).toDateString()}function L(){let e=arguments;return`
<a href=${e[0]}>${e[1]}</a>
<div>${x(e[2])}</div>
`.trim()}})();