diff --git a/src/components/ContentPanel.tsx b/src/components/ContentPanel.tsx index dee91fab..ea54b428 100644 --- a/src/components/ContentPanel.tsx +++ b/src/components/ContentPanel.tsx @@ -1,4 +1,5 @@ import React, { useMemo, useState, useEffect, useRef } from 'react' +import ReactPlayer from 'react-player' import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import rehypeRaw from 'rehype-raw' @@ -29,6 +30,7 @@ import { } from '../services/reactionService' import AuthorCard from './AuthorCard' import { faBooks } from '../icons/customIcons' +import { classifyUrl } from '../utils/helpers' interface ContentPanelProps { loading: boolean @@ -136,6 +138,7 @@ const ContentPanel: React.FC = ({ // Determine if we're on a nostr-native article (/a/) or external URL (/r/) const isNostrArticle = selectedUrl && selectedUrl.startsWith('nostr:') + const isExternalVideo = !isNostrArticle && !!selectedUrl && ['youtube', 'video'].includes(classifyUrl(selectedUrl).type) // Get article links for menu const getArticleLinks = () => { @@ -312,7 +315,31 @@ const ContentPanel: React.FC = ({ highlights={relevantHighlights} highlightVisibility={highlightVisibility} /> - {markdown || html ? ( + {isExternalVideo ? ( + <> +
+ +
+ {activeAccount && ( +
+ +
+ )} + + ) : markdown || html ? ( <> {markdown ? ( renderedMarkdownHtml && finalHtml ? ( diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index cd3be603..071dac6a 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -23,6 +23,12 @@ export const classifyUrl = (url: string | undefined): UrlClassification => { return { type: 'youtube' } } + // Check for popular video hosts + const videoHosts = ['vimeo.com', 'dailymotion.com', 'dai.ly', 'video.twimg.com'] + if (videoHosts.some(host => urlLower.includes(host))) { + return { type: 'video' } + } + // Check for video extensions const videoExtensions = ['.mp4', '.webm', '.ogg', '.mov', '.avi', '.mkv', '.m4v'] if (videoExtensions.some(ext => urlLower.includes(ext))) {