chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
Avatars drawn small load Bluesky's thumbnail, not the full picture
web/src/lib/atoms/Avatar.svelte+10−1
| @@ -1,3 +1,10 @@ | ||
<script module lang="ts"> | ||
/** Where Bluesky's CDN serves a profile picture at full size. */ | ||
const BLUESKY_AVATAR = /^https:\/\/cdn\.bsky\.app\/img\/avatar\//; | ||
/** Where it serves the same picture 128px across. */ | ||
const THUMBNAIL = 'https://cdn.bsky.app/img/avatar_thumbnail/'; | ||
</script> | ||
| ||
<script lang="ts"> | ||
import { hue, identicon } from '#lib/format.ts'; | ||
/** | ||
| @@ -13,9 +20,11 @@ | ||
}: { name: string; did?: string; size?: 'lg' | 'xl'; src?: string | null } = $props(); | ||
let cls = $derived(size ? `av ${size}` : 'av'); | ||
const seed = $derived(did ?? name); | ||
/** The thumbnail wherever it is drawn small: a twentieth of the bytes. */ | ||
const shown = $derived(size === 'xl' ? src : src?.replace(BLUESKY_AVATAR, THUMBNAIL)); | ||
web/src/lib/atoms/Avatar.svelteline 24
| ||
</script> | ||
| ||
{#if src}<img class={cls} {src} alt="" />{:else}<svg | ||
{#if shown}<img class={cls} src={shown} alt="" />{:else}<svg | ||
class="{cls} id" | ||
style="--h:{hue(seed)}" | ||
viewBox="-1 -1 7 7" | ||