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);
const profile = await fetchProfile({ [key]: params.acct });
const handle = await getHandle(params.acct, profile);
res.type = 'profile';
res.title = `View @${handle}'s profile on Ditto`;
res.description = profile.meta.about || `@${handle}'s Nostr profile`;
Object.assign(res, {
type: 'profile',
title: `View @${handle}'s profile on Ditto`,
description: profile.meta.about || `@${handle}'s Nostr profile`,
});
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) {
const { description, image, title } = await getStatusInfo(params.statusId);
res.description = description;
res.image = image;
res.title = title;
Object.assign(res, { description, title });
if (image) Object.assign(res, { image });
}
} catch (e) {
console.debug('Error getting OpenGraph metadata information:');