diff --git a/examples/panes/bookmark.js b/examples/panes/bookmark.js index fa73c67..f1e7946 100644 --- a/examples/panes/bookmark.js +++ b/examples/panes/bookmark.js @@ -1,7 +1,10 @@ -// Pod-local pane for bookmark:Bookmark (dc:title / bookmark:recalls / dcterms:created). +// Pod-local pane for bookmark:Bookmark. +// Core: dc:title / bookmark:recalls / dcterms:created. +// Enrichment (optional, rendered when present): dc:description (summary), +// schema:keywords (tags), schema:image (hero), schema:datePublished. // Loaded by the `--browser panes` data browser from /public/panes/. // Contract: export default { canHandle(node, h) -> bool, render(node, h) -> htmlString } -// h = { escape, prop, propAll, idOf, types, host, fmtDate, localName }. +// h = { escape, prop, propAll, first, idOf, types, host, fmtDate, localName }. export default { canHandle(node, h) { @@ -14,18 +17,71 @@ export default { const site = h.host(url); const date = h.fmtDate(h.first(h.prop(node, 'created'))); const fav = url ? h.escape(new URL('/favicon.ico', url).href) : ''; - return `
-
Bookmark
- - -
-
${h.escape(title)}
-
${h.escape(site)}
+ + // Enrichment — all optional. + const desc = h.first(h.prop(node, 'description')); + const tags = h.propAll(node, 'keywords').map(t => h.first(t)).filter(Boolean); + const img = h.idOf(h.prop(node, 'image')); + const published = h.fmtDate(h.first(h.prop(node, 'datePublished'))); + + const hero = img + ? `` + : ''; + const rule = desc ? `
` : ''; + // Render the summary as paragraphs (split on blank lines); first is the lead. + const paras = desc ? String(desc).split(/\n\s*\n/).map(p => p.trim()).filter(Boolean) : []; + const summary = paras.length + ? `
${paras.map((p, i) => + `

${h.escape(p)}

`).join('')}
` + : ''; + const chips = tags.length + ? `
${tags.map(t => `${h.escape(t)}`).join('')}
` + : ''; + const meta = [published ? `published ${h.escape(published)}` : '', date ? `saved ${h.escape(date)}` : ''] + .filter(Boolean).join(' · '); + + return ` +
+
Bookmark
+
+ + ${rule} + ${summary} + ${chips} +
+ Open ↗ + ${meta ? `${meta}` : ''}
- -
- Open ↗ - ${date ? `saved ${h.escape(date)}` : ''}
`; }