/* FAQ SCHEMA */ safe(()=>{ const words=[...new Set(post.innerText.match(/\b[a-z]{6,15}\b/g)||[])].slice(0,2); if(!words.length) return; const schema=words.map(w=>({ "@type":"Question", "name":"What is "+w+"?", "acceptedAnswer":{"@type":"Answer","text":w+" explained clearly."} })); const s=document.createElement("script"); s.type="application/ld+json"; s.text=JSON.stringify({ "@context":"https://schema.org", "@type":"FAQPage", "mainEntity":schema }); document.head.appendChild(s); },"FAQ"); }catch(e){ console.error("SEO module error:",e); } }); })(); (function(){ document.addEventListener("DOMContentLoaded",function(){ try{ const safeFetch=async(url)=>{ try{ const r=await fetch(url); return await r.json(); }catch(e){ console.warn("Fetch fail:",url); return null; } }; /* READING TIME */ (()=>{ const post=document.querySelector(".post-body"); const el=document.querySelector(".reading-time"); if(!post||!el) return; const words=post.innerText.split(/\s+/).length; el.textContent=Math.max(1,Math.ceil(words/200))+" min read"; })(); /* RELATED */ (async()=>{ const c=document.getElementById("related-grid"); if(!c) return; const data=await safeFetch("/feeds/posts/default?alt=json&max-results=6"); if(!data) return; let html=""; (data.feed.entry||[]).forEach(e=>{ let url="#",img="https://picsum.photos/400/250"; e.link.forEach(l=>l.rel==="alternate"&(url=l.href)); if(e.media$thumbnail) img=e.media$thumbnail.url.replace("s72-c","w400-h250"); html+=`

${e.title.$t}

`; }); c.innerHTML=html||"

No posts found

"; })(); }catch(e){ console.error("UI module error:",e); } }); })();