Something went wrong. Try again.
Send a link from your phone's share sheet and have it open automatically on another device.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192import { useState } from "react";import type { BookmarkRecord } from "@linkport/atproto";import { destLabel, faviconCandidates, parseUrl, resolveDest, timeAgo, topicTags,} from "@linkport/atproto/display";
export function Row({ rec, deviceNames, aliases,}: { rec: BookmarkRecord; /** Routing rkey -> display name, for the destination tag. */ deviceNames: Map<string, string>; /** See destAliases — keeps this tag consistent with the filter pills. */ aliases: Map<string, string>;}) { // Step through the favicon candidates on load error; when they're exhausted // fall back to a host-initial monogram, which reads better than a broken tile. const [iconIdx, setIconIdx] = useState(0); const [thumbFailed, setThumbFailed] = useState(false);
const { host, path } = parseUrl(rec.subject); const favicon = faviconCandidates(rec)[iconIdx]; const ago = timeAgo(rec.createdAt); const tags = topicTags(rec.tags, 4); const dest = resolveDest(rec.tags, aliases); // Broadcasts are the default and repeat down the whole feed, so they get the // quiet chip; the ink fill is reserved for links routed at one device, which // then stand out. Same rule the app's BookmarkRow follows. const isBroadcast = dest === "all";
return ( <li className="row"> <a className="row-link" href={rec.subject} target="_blank" rel="noreferrer noopener"> <span className={isBroadcast ? "dest dest-broadcast" : "dest"}> → {destLabel(dest, deviceNames)} </span>
<h2 className="row-title">{rec.title || host}</h2>
<div className="row-body"> <div className="row-meta"> {rec.description && <p className="row-desc">{rec.description}</p>} {tags.length > 0 && ( <ul className="tags"> {tags.map((tag) => ( <li key={tag} className="tag"> {tag} </li> ))} </ul> )} </div> {rec.image && !thumbFailed && ( <img className="thumb" src={rec.image} alt="" loading="lazy" onError={() => setThumbFailed(true)} /> )} </div>
<div className="row-foot"> <span className="favicon"> {favicon ? ( <img key={favicon} src={favicon} alt="" loading="lazy" onError={() => setIconIdx((i) => i + 1)} /> ) : ( host.charAt(0).toUpperCase() )} </span> <span className="row-url">{host + path}</span> {ago && <time className="row-ago">{ago}</time>} </div> </a> </li> );}