Created
September 21, 2023 08:25
-
-
Save SebastianUdden/d70353d6c55464fd65b7d6a824e081ee to your computer and use it in GitHub Desktop.
formatTextLink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const formatTextLink = (text: string, link?: string) => { | |
| const split1 = text.split("["); | |
| const beforeLink = split1[0]; | |
| const split2 = split1[1].split("]"); | |
| const linkText = split2[0]; | |
| const afterLink = split2[1]; | |
| return ( | |
| <> | |
| {beforeLink} | |
| <LinkInText | |
| href={link || "/"} | |
| rel="noopener noreferrer" | |
| target="_blank" | |
| onClick={(e) => e.stopPropagation()} | |
| > | |
| {linkText} | |
| <Span> | |
| <Icon type="externalLink" size="14px" /> | |
| </Span> | |
| </LinkInText> | |
| {afterLink} | |
| </> | |
| ); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment