From 6063a3d2dab070229ce3ff3dbb4f235eeb64ad5b Mon Sep 17 00:00:00 2001 From: Ahtesham Quraish Date: Wed, 6 May 2026 17:33:21 +0500 Subject: [PATCH 1/2] fix: add video captions on the video detail page (#3284) * fix: add captions of video --------- Co-authored-by: Ahtesham Quraish --- .../VideoDetailPage.tsx | 18 ++- .../VideoJsPlayer.tsx | 63 ++++++++- .../VideoSeriesDetailPage.test.tsx | 132 +++++++++++++++++- .../VideoSeriesDetailPage.tsx | 21 ++- .../videoStructuredData.ts | 38 +++++ 5 files changed, 263 insertions(+), 9 deletions(-) create mode 100644 frontends/main/src/app-pages/VideoPlaylistCollectionPage/videoStructuredData.ts diff --git a/frontends/main/src/app-pages/VideoPlaylistCollectionPage/VideoDetailPage.tsx b/frontends/main/src/app-pages/VideoPlaylistCollectionPage/VideoDetailPage.tsx index f425683fb9..063a1cf9a9 100644 --- a/frontends/main/src/app-pages/VideoPlaylistCollectionPage/VideoDetailPage.tsx +++ b/frontends/main/src/app-pages/VideoPlaylistCollectionPage/VideoDetailPage.tsx @@ -28,6 +28,7 @@ import { FeatureFlags } from "@/common/feature_flags" import { useFeatureFlagsLoaded } from "@/common/useFeatureFlagsLoaded" import { notFound } from "next/navigation" import SharePopover from "@/components/SharePopover/SharePopover" +import { buildVideoStructuredData } from "./videoStructuredData" const NEXT_PUBLIC_ORIGIN = process.env.NEXT_PUBLIC_ORIGIN @@ -388,7 +389,6 @@ const VideoDetailPage: React.FC = ({ const playlist = playlistData as VideoPlaylistResource | undefined const video = resource as VideoResource | undefined - const sources = useMemo( () => video @@ -406,6 +406,7 @@ const VideoDetailPage: React.FC = ({ : null const topics = video?.topics ?? [] + const captionUrls = video?.video?.caption_urls ?? [] const playlistLabel = playlist?.title || "Video Collection" @@ -442,12 +443,26 @@ const VideoDetailPage: React.FC = ({ } }, [isLoading, videoId]) + // VideoObject JSON-LD for Google search indexing. + // See: https://developers.google.com/search/docs/appearance/structured-data/video + const structuredData = !isLoading ? buildVideoStructuredData(video) : null + if (!showVideoPlaylistPage) { return flagsLoaded ? notFound() : null } return ( + {structuredData && ( + injection. + // See: https://developers.google.com/search/docs/appearance/structured-data/video + const structuredData = !isLoading ? buildVideoStructuredData(video) : null + if (!showVideoPlaylistPage) { return flagsLoaded ? notFound() : null } return ( + {structuredData && ( +