Something went wrong. Try again.
doll.systems community website
Something went wrong. Try again.
12345678910111213141516171819202122/** @typedef {{ name: string, url: string }} Link *//** @typedef {{ name: string, featureImage?: { src: string, alt: string }, links?: Link[] }} AuthorData */import { avatarSource } from './image-files.mjs';
/** @param {Link[] | undefined} links */export function blueskyActor(links) { for (const { url: href } of links ?? []) { const url = new URL(href); const actor = url.pathname.match(/^\/profile\/([^/]+)\/?$/)?.[1]; if (url.protocol === 'https:' && url.hostname === 'bsky.app' && actor) return decodeURIComponent(actor); }}
/** @param {string} id @param {AuthorData} author */export function authorImage(id, author) { if (author.featureImage) return { image: author.featureImage }; const actor = blueskyActor(author.links); if (!actor) return {}; return { actor, image: { src: avatarSource(id), alt: `${author.name}'s Bluesky avatar.` } };}