use Object.assign to fill template opts

This commit is contained in:
Siddharth Singh 2024-08-06 00:37:14 +05:30
parent af70065d84
commit f48d8e0a66
No known key found for this signature in database

View file

@ -43,17 +43,20 @@ async function buildTemplateOpts(params: PathParams, url: string): Promise<OpenG
console.log(key); console.log(key);
const profile = await fetchProfile({ [key]: params.acct }); const profile = await fetchProfile({ [key]: params.acct });
const handle = await getHandle(params.acct, profile); const handle = await getHandle(params.acct, profile);
res.type = 'profile';
res.title = `View @${handle}'s profile on Ditto`; Object.assign(res, {
res.description = profile.meta.about || `@${handle}'s Nostr profile`; type: 'profile',
title: `View @${handle}'s profile on Ditto`,
description: profile.meta.about || `@${handle}'s Nostr profile`,
});
if (profile.meta.picture) { if (profile.meta.picture) {
res.image = { url: profile.meta.picture, h: 150, w: 150 }; Object.assign(res, { image: { url: profile.meta.picture, h: 150, w: 150 } });
} }
} else if (params.statusId) { } else if (params.statusId) {
const { description, image, title } = await getStatusInfo(params.statusId); const { description, image, title } = await getStatusInfo(params.statusId);
res.description = description; Object.assign(res, { description, title });
res.image = image; if (image) Object.assign(res, { image });
res.title = title;
} }
} catch (e) { } catch (e) {
console.debug('Error getting OpenGraph metadata information:'); console.debug('Error getting OpenGraph metadata information:');