Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

added links for comments

aakash23300ae7ef743aae
diff --git a/apps/web/ui/links/link-card.tsx b/apps/web/ui/links/link-card.tsx
index 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({
<Tooltip
content={
<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.tsx
similarity index 63%
rename from apps/web/ui/links/linkifyText.tsx
rename to apps/web/ui/links/linkify-comments.tsx
index 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>
);
}