Skip to content

Commit

Permalink
ignore empty urls and not throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
bshahid331 committed Aug 24, 2023
1 parent 2c739ce commit 8e0d4d0
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function getFormattedDate(date: any) {
return month + '/' + day + '/' + year;
}

function Socials(externalURL: string, socials: any) {
function Socials(externalURL: any, socials: any) {
let formattedSocials: [{ social: string; socialLink: string }] = [
{
social: 'Website',
Expand Down Expand Up @@ -64,9 +64,9 @@ function Socials(externalURL: string, socials: any) {
};
const withIcons = (
<>
{externalURL && (
{externalURL && externalURL.url && externalURL.url !== '' && (
<div>
<SocialIcon url={externalURL} href={externalURL} {...socialProps} />{' '}
<SocialIcon url={externalURL.url} href={externalURL.url} {...socialProps} />{' '}
</div>
)}
{socials &&
Expand All @@ -75,11 +75,17 @@ function Socials(externalURL: string, socials: any) {
socials[social] && socials[social].url
? socials[social].url
: socials[social];
return (
<div key={social}>
<SocialIcon url={socialLink} href={socialLink} {...socialProps} />{' '}
</div>
);

// Only return the SocialIcon component if the socialLink is not null or an empty string
if (socialLink && socialLink.url && socialLink.url !== '') {
return (
<div key={social}>
<SocialIcon url={socialLink} href={socialLink} {...socialProps} />{' '}
</div>
);
} else {
return null;
}
})}
</>
);
Expand Down

1 comment on commit 8e0d4d0

@vercel
Copy link

@vercel vercel bot commented on 8e0d4d0 Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.