From a2cf5c90b9acd0cb3ab432c261f51ad2d2b6c11c Mon Sep 17 00:00:00 2001 From: OFF0 Date: Wed, 9 Aug 2023 14:48:46 +0200 Subject: [PATCH] profile: fix displaying website metadata was using the wrong key and did not update --- src/profiles.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/profiles.ts b/src/profiles.ts index 104e7f3..1a47e0a 100644 --- a/src/profiles.ts +++ b/src/profiles.ts @@ -37,7 +37,7 @@ const transformMetadata = (data: unknown): Profile | undefined => { name, ...(hasAboutString && {about: data.about as string}), ...(hasPictureString && {picture: data.picture as string}), - ...(hasWebsite && {hasWebsite: data.website as string}) + ...(hasWebsite && {website: data.website as string}) }; }; @@ -126,4 +126,15 @@ export const renderProfile = (pubkey: string) => { detail?.append(...content); } } + if (metadata.website) { + const website = detail.querySelector('[data-website]'); + if (website) { + const url = metadata.website.toLowerCase().startsWith('http') ? metadata.website : `https://${metadata.website}`; + const [content] = parseTextContent(url); + website.replaceChildren(...content); + (website as HTMLDivElement).hidden = false; + } else { + detail.append(elem('div', {data: {website: ''}}, metadata.name)); + } + } };