diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 4b8b601f..09f35229 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -165,17 +165,17 @@ const config: Config = { // label: "πŸ“Ί Broadcast", // to: "https://codeharborhub-broadcast-web.vercel.app/", // }, - ], - }, - { - to: "/blogs", - html: 'πŸ“° Blogs', - }, - { - type: "dropdown", - html: 'πŸ”— More', - position: "left", - items: [ + ], + }, + { + to: "/blogs", + html: 'πŸ“° Blogs', + }, + { + type: "dropdown", + html: 'πŸ”— More', + position: "left", + items: [ { label: "πŸ“œProjects", to: "#", @@ -195,12 +195,16 @@ const config: Config = { }, { label: "πŸ“Ί Broadcast", - to: "https://www.youtube.com/recodehive", + to: "/broadcasts/", }, { label: "πŸŽ™οΈ Podcast", - to: "podcasts/", + to: "/podcasts/", }, + + ], + }, + ], }, { @@ -208,6 +212,7 @@ const config: Config = { position: "right", value: '
', }, + // { // type: "dropdown", // html: '🏷️ Tags', diff --git a/src/pages/broadcasts/details.tsx b/src/pages/broadcasts/details.tsx new file mode 100644 index 00000000..c4d96b80 --- /dev/null +++ b/src/pages/broadcasts/details.tsx @@ -0,0 +1,114 @@ +import React, { useState, useEffect } from 'react'; +import Layout from '@theme/Layout'; +import type { ReactElement } from 'react'; +import { useLocation } from '@docusaurus/router'; +import './index.css'; + +interface VideoData { + id: string; + youtubeUrl: string; + type: 'video' | 'shorts'; +} + +interface LocationState { + video: VideoData; +} + +// Function to extract YouTube video ID from URL +const getYoutubeVideoId = (url: string): string => { + let videoId = ''; + const normalMatch = url.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\s]+)/); + const shortsMatch = url.match(/youtube\.com\/shorts\/([^&\s]+)/); + + if (normalMatch) { + videoId = normalMatch[1]; + } else if (shortsMatch) { + videoId = shortsMatch[1]; + } + return videoId; +}; + +export default function VideoDetails(): ReactElement { + const location = useLocation(); + const state = location.state as LocationState; + const video = state?.video; + const [title, setTitle] = useState('Loading...'); + + useEffect(() => { + const fetchVideoTitle = async () => { + if (!video?.youtubeUrl) return; + + try { + const response = await fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(video.youtubeUrl)}&format=json`); + const data = await response.json(); + setTitle(data.title); + } catch (error) { + setTitle('Video Title Unavailable'); + console.error('Error fetching video title:', error); + } + }; + + fetchVideoTitle(); + }, [video?.youtubeUrl]); + + // Random descriptive text about videos + const descriptions = [ + "Watch engaging content that inspires and educates.", + "Experience the power of visual storytelling.", + "Join us on a journey of learning through video.", + "Explore new concepts through dynamic video content.", + "Get inspired by expert insights and demonstrations.", + "Discover trending topics and timely tutorials.", + "Learn from the best in the field.", + "Stay updated with the latest trends and techniques.", + "Enhance your skills through visual learning.", + ]; + + // Get a random description + const randomDescription = descriptions[Math.floor(Math.random() * descriptions.length)]; + + if (!video) { + return ( + +
+

Video Not Found

+

Sorry, we couldn't find the video you're looking for.

+
+
+ ); + } + + return ( + +
+
+
+
+
+ {title} +
+
+ {video.type === 'shorts' ? 'πŸ“± Shorts' : 'πŸŽ₯ Video'} +
+
+
+

{randomDescription}

+
+
+