diff --git a/components/linkify.tsx b/components/linkify.tsx new file mode 100644 index 0000000..e8bde12 --- /dev/null +++ b/components/linkify.tsx @@ -0,0 +1,33 @@ +import React from 'react'; + +const URL_REGEX = /(https?:\/\/[^\s]+)/g; + +export function Linkify({ children }: { children: React.ReactNode }) { + if (typeof children !== 'string') { + return <>{children}; + } + + const parts = children.split(URL_REGEX); + + return ( + <> + {parts.map((part, i) => { + if (part.match(URL_REGEX)) { + return ( + e.stopPropagation()} + > + {part} + + ); + } + return {part}; + })} + + ); +} diff --git a/components/video-page-content.tsx b/components/video-page-content.tsx index 5fb2692..100e97a 100644 --- a/components/video-page-content.tsx +++ b/components/video-page-content.tsx @@ -74,6 +74,7 @@ import { } from '@/components/ui/dropdown-menu'; import { cn } from '@/lib/utils'; import { parseVideoUrl, getThumbnailUrl, fetchVideoMetadata, type VideoSource } from '@/lib/video-providers'; +import { Linkify } from '@/components/linkify'; interface Version { id: string; @@ -2380,7 +2381,7 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi ) : ( - comment.content &&

{comment.content}

+ comment.content &&

{comment.content}

)} {comment.voiceUrl && ( @@ -2523,7 +2524,7 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi ) : ( - reply.content &&

{reply.content}

+ reply.content &&

{reply.content}

)} {reply.voiceUrl && (