Skip to content

Commit

Permalink
Support for phone links
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrootBuck authored and xitanggg committed Jul 4, 2023
1 parent ed8d70b commit 0e5fe32
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/app/components/Resume/ResumePDF/ResumePDFProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,35 @@ export const ResumePDFProfile = ({
}
}

const shouldUseLinkWrapper = ["email", "url"].includes(key);
const shouldUseLinkWrapper = ["email", "url", "phone"].includes(key);
const Wrapper = ({ children }: { children: React.ReactNode }) => {
if (!shouldUseLinkWrapper) return <>{children}</>;

return (
<ResumePDFLink
src={key === "email" ? `mailto:${value}` : `https://${value}`}
isPDF={isPDF}
>
{children}
</ResumePDFLink>
);
switch (key) {
case "email":
return (
<ResumePDFLink src={`mailto:${value}`} isPDF={isPDF}>
{children}
</ResumePDFLink>
);

case "phone":
return (
<ResumePDFLink
src={`tel:${value.replace(/[\(\)\s-]/g, "")}`} // This regex "cleans" the number
isPDF={isPDF}
>
{children}
</ResumePDFLink>
);

default:
return (
<ResumePDFLink src={`https://${value}`} isPDF={isPDF}>
{children}
</ResumePDFLink>
);
}
};

return (
Expand Down

0 comments on commit 0e5fe32

Please sign in to comment.