diff --git a/src/middleware/serveStaticWithOG.ts b/src/middleware/serveStaticWithOG.ts index d6f713ba..f8939229 100644 --- a/src/middleware/serveStaticWithOG.ts +++ b/src/middleware/serveStaticWithOG.ts @@ -123,7 +123,7 @@ const normalizeHandle = async (handle: string) => { return ''; }; -const getKind0 = async (handle: string | undefined): Promise> => { +const getKind0 = async (handle: string | undefined): Promise => { const id = await normalizeHandle(handle || ''); const kind0 = await getAuthor(id); @@ -186,10 +186,11 @@ const buildMetaTags = async (params: PathParams, url: string): Promise = const kind0 = await getKind0(params.acct); const { description, image } = await getStatus(params.statusId || ''); + const handle = kind0.nip05 || kind0.name || 'npub1xxx'; if (params.acct && params.statusId) { return tpl({ - title: `View @${kind0.name}'s post on Ditto`, + title: `View @${handle}'s post on Ditto`, type: 'article', image, description, @@ -197,10 +198,18 @@ const buildMetaTags = async (params: PathParams, url: string): Promise = }); } else if (params.acct) { return tpl({ - title: `View @${kind0.nip05 || kind0.name || 'npub1xxx'}'s profile on Ditto`, + title: `View @${handle}'s profile on Ditto`, type: 'profile', description: kind0.about || '', url, + image: kind0.picture + ? { + url: kind0.picture, + // Time will tell if this is fine. + h: 150, + w: 150, + } + : undefined, }); } else if (params.statusId) { return tpl({