Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
at main 32 lines 757 B view raw
1import type { MarkupLinkProps } from "@hey/types/misc"; 2import { Link } from "react-router"; 3import injectReferrerToUrl from "@/helpers/injectReferrerToUrl"; 4import stopEventPropagation from "@/helpers/stopEventPropagation"; 5import truncateUrl from "@/helpers/truncateUrl"; 6 7const ExternalLink = ({ title }: MarkupLinkProps) => { 8 let href = title; 9 10 if (!href) { 11 return null; 12 } 13 14 if (!href.includes("://")) { 15 href = `https://${href}`; 16 } 17 18 const url = injectReferrerToUrl(href); 19 20 return ( 21 <Link 22 onClick={stopEventPropagation} 23 rel="noopener" 24 target={url.includes(location.host) ? "_self" : "_blank"} 25 to={url} 26 > 27 {title ? truncateUrl(title, 30) : title} 28 </Link> 29 ); 30}; 31 32export default ExternalLink;