Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions app/(website)/user/[id]/components/UserSocials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,34 @@
};

export default function UserSocials({ metadata }: UserSocialsProps) {
const linkElement = (title: string, link: string) => (
<Link className="font-bold text-primary hover:underline" href={link}>
{title}
</Link>
);
const normalizeUrl = (url?: string) => {
if (!url)
return "#";
if (url.startsWith("http://") || url.startsWith("https://"))
return url;
return `https://${url}`;
};

Check failure on line 43 in app/(website)/user/[id]/components/UserSocials.tsx

View workflow job for this annotation

GitHub Actions / build

Trailing spaces not allowed
const linkElement = (title: string, link: string) => {
if (link.startsWith("http://") || link.startsWith("https://")) {
return (
<a
className="font-bold text-primary hover:underline"
href={link}
target="_blank"
rel="noopener noreferrer"
>
{title}
</a>
);
}

return (
<Link className="font-bold text-primary hover:underline" href={link}>
{title}
</Link>
);
};

const htmlTag = (v: keyof UserMetadataResponse, content: string) => {
switch (v) {
Expand All @@ -59,7 +82,7 @@
</CopyElement>
);
case "website":
return linkElement(content, content);
return linkElement(content, normalizeUrl(content));
default:
return (
<span className="font-bold text-muted-foreground">{content}</span>
Expand Down
Loading