your personal website on atproto - mirror blento.app

Merge pull request #142 from flo-bit/custom-domains-editing

fix og image

authored by Florian and committed by GitHub c1fcf4a6 103a262e

+11 -4
+11 -4
src/routes/[handle=handle]/og.png/+server.ts
··· 1 + import { getCDNImageBlobUrl } from '$lib/atproto/methods.js'; 1 2 import type { UserCache } from '$lib/types'; 2 3 import { loadData } from '$lib/website/load'; 3 4 import type { Handle } from '@atcute/lexicons'; 5 + import { isDid } from '@atcute/lexicons/syntax'; 4 6 import { ImageResponse } from '@ethercorps/sveltekit-og'; 5 7 6 8 function escapeHtml(str: string): string { ··· 13 15 } 14 16 15 17 export async function GET({ params, platform }) { 16 - const handle = params.handle; 17 - 18 18 const cache = platform?.env?.USER_DATA_CACHE as unknown; 19 19 20 20 const data = await loadData(params.handle as Handle, cache as UserCache); 21 21 22 - const image = data.profile.avatar; 22 + let image: string | undefined = data.profile.avatar; 23 + 24 + if (data.publication.icon) { 25 + image = 26 + getCDNImageBlobUrl({ did: data.did, blob: data.publication.icon }) ?? data.profile.avatar; 27 + } 28 + 29 + const name = data.publication?.name ?? data.profile.displayName ?? data.profile.handle; 23 30 24 31 const htmlString = ` 25 32 <div class="flex flex-col p-8 w-full h-full bg-neutral-900"> 26 33 <div class="flex items-center mb-8 mt-16"> 27 34 <img src="${escapeHtml(image ?? '')}" width="128" height="128" class="rounded-full" /> 28 35 29 - <h1 class="text-neutral-50 text-7xl ml-4">${escapeHtml(handle)}</h1> 36 + <h1 class="text-neutral-50 text-7xl ml-4">${escapeHtml(name)}</h1> 30 37 </div> 31 38 32 39 <p class="mt-8 text-4xl text-neutral-300">Check out my blento</p>