Changeset 5f3f9ec in Klonkt for src/routes/circle.js
- Timestamp:
- 06/30/2026 11:06:00 PM (2 months ago)
- Branches:
- main
- Children:
- 86fa2d2
- Parents:
- e091add
- File:
-
- 1 edited
-
src/routes/circle.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/circle.js
re091add r5f3f9ec 19 19 try { return s ? JSON.parse(s) : []; } catch { return []; } 20 20 } 21 function mediaImage(media_json) { 21 // The cover image + (separately) a cover video from a remote note's media. NEVER use a video/audio 22 // item as the cover image — that produced a broken <img> for an animated cover that federated as an 23 // MP4 (the video becomes a <video> instead). 24 function coverMedia(media_json) { 22 25 const media = safeJson(media_json).map((m) => ({ ...m, url: safeUrl(m.url) })).filter((m) => m.url); 23 return media.find((m) => /image/i.test(m.type || '')) || media[0] || null; 26 const video = media.find((m) => /video/i.test(m.type || '')) || null; 27 const image = media.find((m) => /image/i.test(m.type || '')) 28 || (media[0] && !/(video|audio)/i.test(media[0].type || '') ? media[0] : null); 29 return { image, video }; 24 30 } 25 31 function htmlToText(html) { … … 37 43 const titleM = (r.content || '').match(/^\s*<p>\s*<strong>([\s\S]*?)<\/strong>/i); 38 44 const realTitle = titleM ? htmlToText(titleM[1]).trim() : ''; 39 const image = mediaImage(r.media_json);45 const cover = coverMedia(r.media_json); 40 46 const name = r.author_name || r.author_handle || 'Onbekend'; 41 47 return { … … 46 52 : (text ? (text.length > 90 ? text.slice(0, 90) + '…' : text) : name), 47 53 excerpt: '', 48 cover_image_url: image ? image.url : null, 54 cover_image_url: cover.image ? cover.image.url : null, 55 cover_video_url: cover.video ? cover.video.url : null, 49 56 published_at: r.published, 50 57 created_at: r.published,
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)