mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-20 11:24:05 -06:00
5 lines
771 B
JavaScript
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")})}})})})} |