diff --git a/client/src/components/bunny-video-modal.tsx b/client/src/components/bunny-video-modal.tsx index a85b0d4..750e81c 100644 --- a/client/src/components/bunny-video-modal.tsx +++ b/client/src/components/bunny-video-modal.tsx @@ -111,7 +111,9 @@ export default function BunnyVideoModal({ video, isOpen, onClose, onEdit, videos const getShareUrl = () => { if (!video?.id) return window.location.origin; - return `${window.location.origin}?video=${video.id}`; + // Use custom domain if set, otherwise current domain + const baseUrl = import.meta.env.VITE_SHARE_DOMAIN || window.location.origin; + return `${baseUrl}/video/${video.id}`; }; const copyToClipboard = async () => { diff --git a/client/src/pages/VideoPage.tsx b/client/src/pages/VideoPage.tsx index 2483443..2b08cec 100644 --- a/client/src/pages/VideoPage.tsx +++ b/client/src/pages/VideoPage.tsx @@ -70,6 +70,52 @@ export default function VideoPage() { const recommendedVideos = recommendedResponse?.videos?.filter(v => v.id !== videoId) || []; + // Update page meta tags for social sharing + useEffect(() => { + if (currentVideo) { + // Update page title + document.title = `${currentVideo.title} | go4.video`; + + // Update meta description + const metaDescription = document.querySelector('meta[name="description"]'); + if (metaDescription) { + metaDescription.setAttribute('content', currentVideo.description || `Watch ${currentVideo.title} on go4.video`); + } + + // Update Open Graph tags + const updateMetaTag = (property: string, content: string) => { + let meta = document.querySelector(`meta[property="${property}"]`); + if (!meta) { + meta = document.createElement('meta'); + meta.setAttribute('property', property); + document.head.appendChild(meta); + } + meta.setAttribute('content', content); + }; + + updateMetaTag('og:title', currentVideo.title); + updateMetaTag('og:description', currentVideo.description || `Watch ${currentVideo.title} on go4.video`); + updateMetaTag('og:image', currentVideo.thumbnailUrl); + updateMetaTag('og:url', window.location.href); + updateMetaTag('og:type', 'video.other'); + updateMetaTag('og:video:duration', currentVideo.duration.toString()); + + // Update Twitter Card tags + const updateTwitterTag = (name: string, content: string) => { + let meta = document.querySelector(`meta[name="${name}"]`); + if (!meta) { + meta = document.createElement('meta'); + meta.setAttribute('name', name); + document.head.appendChild(meta); + } + meta.setAttribute('content', content); + }; + + updateTwitterTag('twitter:title', currentVideo.title); + updateTwitterTag('twitter:description', currentVideo.description || `Watch ${currentVideo.title} on go4.video`); + updateTwitterTag('twitter:image', currentVideo.thumbnailUrl); + } + }, [currentVideo]); // Track video view @@ -85,7 +131,9 @@ export default function VideoPage() { const getShareUrl = () => { if (!currentVideo?.id) return window.location.origin; - return `${window.location.origin}/video/${currentVideo.id}`; + // Use custom domain if set, otherwise current domain + const baseUrl = import.meta.env.VITE_SHARE_DOMAIN || window.location.origin; + return `${baseUrl}/video/${currentVideo.id}`; }; const copyToClipboard = async () => {