A React component library for rendering common AT Protocol records for applications such as Bluesky and Leaflet.
1import type { ProfileRecord } from "../types/bluesky";
2
3interface LegacyBlobRef {
4 ref?: { $link?: string };
5 cid?: string;
6}
7
8export function getAvatarCid(
9 record: ProfileRecord | undefined,
10): string | undefined {
11 const avatar = record?.avatar as LegacyBlobRef | undefined;
12 if (!avatar) return undefined;
13 if (typeof avatar.cid === "string") return avatar.cid;
14 return avatar.ref?.$link;
15}