feat(cards): X/Twitter oEmbed support and image URL card detection; render oEmbed HTML in UI

This commit is contained in:
Thomas Cravey 2025-08-17 16:03:22 -05:00
parent 9e95ccdca4
commit 15f7f3ac96
2 changed files with 37 additions and 1 deletions

View file

@ -33,7 +33,7 @@ function processLinks(scope){ const links = scope.querySelectorAll('a[href]:not(
// Fetch and render card
fetch('/api/linkcard?url='+encodeURIComponent(a.href)).then(r=>r.json()).then(card=>{
if(!card) return;
if(card.title||card.description||card.image){
if(card.title||card.description||card.image||card.html){
const c=document.createElement('div'); c.className='card'; var html='';
if(card.image){ html += '<div><img src="'+card.image+'" alt="" style="max-width:160px;max-height:120px;object-fit:cover;border-radius:.25rem"></div>'; }
html += '<div style="flex:1;margin-left:.5rem">';
@ -43,6 +43,7 @@ function processLinks(scope){ const links = scope.querySelectorAll('a[href]:not(
const row = document.createElement('div'); row.style.display='flex'; row.style.alignItems='flex-start'; row.style.gap='.5rem'; row.innerHTML = html;
c.appendChild(row);
c.querySelectorAll('img').forEach(img=> img.addEventListener('load', ()=> pinBottomMulti()));
if(card.html){ const wrap=document.createElement('div'); wrap.innerHTML=card.html; c.appendChild(wrap); }
// Summary control row
const ctrl = document.createElement('div'); ctrl.style.marginTop='.25rem';
const btn = document.createElement('button'); btn.type='button'; btn.title='Summarize this link'; btn.textContent='\u25B6'; btn.style.padding='0 .4rem'; btn.style.fontSize='.9rem';