Fallback to favicon.ico in link previews

This commit is contained in:
Alex Gleason 2024-08-07 21:10:31 -05:00
parent 15c46ec3f0
commit efc121a4ae
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -1,3 +1,4 @@
import { Conf } from '@/config.ts';
import { html } from '@/utils/html.ts';
import { MetadataEntities } from '@/utils/og-metadata.ts';
@ -12,7 +13,7 @@ export function renderMetadata(url: string, { account, status, instance }: Metad
const title = account ? `${account.display_name} (@${account.acct})` : instance.name;
const attachment = status?.media_attachments?.find((a) => a.type === 'image');
const description = status?.content || account?.note || instance.tagline;
const image = attachment?.preview_url || account?.avatar_static || instance.picture;
const image = attachment?.preview_url || account?.avatar_static || instance.picture || Conf.local('/favicon.ico');
const siteName = instance?.name;
const width = attachment?.meta?.original?.width;
const height = attachment?.meta?.original?.height;