From 4b415de2c91c4f46675e0e6da460a109a9dfc811 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Sat, 30 Aug 2025 19:58:59 +0000 Subject: [PATCH] Improve video sharing functionality and page meta tags Update `bunny-video-modal.tsx` to support custom share domains and modify `VideoPage.tsx` to dynamically update meta tags (title, description, Open Graph, Twitter Card) for enhanced social sharing, using `VITE_SHARE_DOMAIN` environment variable for custom domain configuration. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 074b0e4c-6171-43bd-aa98-f9e04623ca14 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/074b0e4c-6171-43bd-aa98-f9e04623ca14/Sy6XHzr --- client/src/components/bunny-video-modal.tsx | 4 +- client/src/pages/VideoPage.tsx | 50 ++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) 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 () => {