From 83c1fa6e4215efed4bfdc6871b05dd02c4c8e0ad Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 20 Nov 2022 23:31:46 +0100 Subject: [PATCH] fix(frontend): embed improvements --- frontend/pages/u/[user]/index.tsx | 45 ++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/frontend/pages/u/[user]/index.tsx b/frontend/pages/u/[user]/index.tsx index 5f95216..e70cd35 100644 --- a/frontend/pages/u/[user]/index.tsx +++ b/frontend/pages/u/[user]/index.tsx @@ -32,6 +32,9 @@ interface Props { export default function Index({ user, partialMembers }: Props) { return ( <> + + {`@${user.username} - pronouns.cc`} +
@@ -89,14 +92,21 @@ function UserHead({ user }: { user: User }) { ) { description = `@${user.username} goes by ${user.names .filter((name) => name.status === WordStatus.Favourite) + .map((name) => name.name) .join(", ")} and uses ${user.pronouns .filter((pronoun) => pronoun.status === WordStatus.Favourite) + .map( + (pronoun) => + pronoun.display_text ?? + pronoun.pronouns.split("/").slice(0, 2).join("/") + ) .join(", ")} pronouns.`; } else if ( user.names?.filter((name) => name.status === WordStatus.Favourite)?.length ) { description = `@${user.username} goes by ${user.names .filter((name) => name.status === WordStatus.Favourite) + .map((name) => name.name) .join(", ")}.`; } else if ( user.pronouns?.filter((pronoun) => pronoun.status === WordStatus.Favourite) @@ -104,21 +114,24 @@ function UserHead({ user }: { user: User }) { ) { description = `@${user.username} uses ${user.pronouns .filter((pronoun) => pronoun.status === WordStatus.Favourite) + .map( + (pronoun) => + pronoun.display_text ?? + pronoun.pronouns.split("/").slice(0, 2).join("/") + ) .join(", ")} pronouns.`; + } else if (user.bio && user.bio !== "") { + description = user.bio.slice(0, 500); } - if (user.bio && user.bio !== "") { - description += `\n\n${user.bio.slice(0, 500)}`; - description.trim(); - } + const domain = + typeof window !== "undefined" ? window.location.origin : process.env.DOMAIN; return ( - {`@${user.username} - pronouns.cc`} - - + {user.avatar_urls && user.avatar_urls.length > 0 ? ( - + ) : ( <> )} - + );