quartz/js/popover.718bae159805a590cda4e9bcb14b9dcc.min.js
2022-03-07 18:45:47 +00:00

5 lines
771 B
JavaScript

function htmlToElement(a){const b=document.createElement('template');return a=a.trim(),b.innerHTML=a,b.content.firstChild}function initPopover(a){const b=a.replace(window.location.origin,"");document.addEventListener("DOMContentLoaded",()=>{fetchData.then(({content:a})=>{const c=[...document.getElementsByClassName("internal-link")];c.forEach(c=>{const d=a[c.dataset.src.replace(b,"")];if(d){const b=`<div class="popover">
<h3>${d.title}</h3>
<p>${removeMarkdown(d.content).split(" ",20).join(" ")}...</p>
<p class="meta">${new Date(d.lastmodified).toLocaleDateString()}</p>
</div>`,a=htmlToElement(b);c.appendChild(a),c.addEventListener("mouseover",()=>{a.classList.add("visible")}),c.addEventListener("mouseout",()=>{a.classList.remove("visible")})}})})})}