The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added links for comments
aakash23300ae7ef743aae
diff --git a/apps/web/ui/links/link-card.tsx b/apps/web/ui/links/link-card.tsxindex 74e40d75cd..5ed148d785 100644--- a/apps/web/ui/links/link-card.tsx+++ b/apps/web/ui/links/link-card.tsx@@ -46,7 +46,7 @@ import { useParams } from "next/navigation";import punycode from "punycode/";import { useContext, useEffect, useMemo, useRef, useState } from "react";import useSWR from "swr";-import LinkifyText from "@/ui/links/linkifyText";+import LinkifyText from "@/ui/links/linkify-comments";export default function LinkCard({props,@@ -289,7 +289,9 @@ export default function LinkCard({<Tooltipcontent={<div className="block max-w-sm px-4 py-2 text-center text-sm text-gray-700">- <LinkifyText text={comments}></LinkifyText>+ <LinkifyText>+ {comments}+ </LinkifyText></div>}>diff --git a/apps/web/ui/links/linkifyText.tsx b/apps/web/ui/links/linkify-comments.tsxsimilarity index 63%rename from apps/web/ui/links/linkifyText.tsxrename to apps/web/ui/links/linkify-comments.tsxindex 5fe62040fe..7f494c270f 100644--- a/apps/web/ui/links/linkifyText.tsx+++ b/apps/web/ui/links/linkify-comments.tsx@@ -1,9 +1,11 @@-export default function LinkifyText({ text }:{text:any}) {++//to convert links in comments clickable+export default function LinkifyText({ children }:{children:string}) {const urlPattern = /(\bhttps?:\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gi;- const renderText = (text:any) => {+ const renderText = (text:string) => {const parts = text.split(urlPattern);- return parts.map((part:any, index:any) => {+ return parts.map((part, index) => {if (part.match(urlPattern)) {return <a href={part} key={index} target="_blank" rel="noopener noreferrer" className="hover:underline">{part}</a>;} else {@@ -14,7 +16,7 @@ export default function LinkifyText({ text }:{text:any}) {return (<div>- {renderText(text)}+ {renderText(children)}</div>);}