Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849// When the article was published, how long it takes to read, its tags and its// other authors — all from the document record already in detection state.//// Synchronous like every card's `render`: there is nothing to fetch here, so// the line is drawn on the first paint and again on every redraw. Missing// fields simply remove their part of the line; the article itself never waits// on them.
import { articleDetails, articleMetaLine } from '../../lib/article'import { $ } from '../dom'import type { Card, CardHost } from './card'
export const articleCard: Card = { id: 'article',
render(host) { const state = host.state() const doc = state?.doc const box = $('article-details') if (!doc) { box.hidden = true return } const details = articleDetails(doc.record) // The owner card already names the publication's account; repeating it as // a contributor adds a line without adding a person. const contributors = details.contributors.filter((c) => c.did !== state?.pub?.did) const line = articleMetaLine({ ...details, contributors }) const meta = $('article-meta') meta.textContent = line meta.hidden = !line meta.title = contributors .map((c) => (c.role ? `${c.name} (${c.role})` : c.name)) .join('\n')
const tags = $('article-tags') tags.replaceChildren( ...details.tags.map((tag) => { const chip = document.createElement('span') chip.className = 'article-tag' chip.textContent = `#${tag}` return chip }), ) tags.hidden = details.tags.length === 0 box.hidden = !line && details.tags.length === 0 },}