diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 49882505..3648297a 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -199,7 +199,7 @@ const config: Config = { }, { label: "🎙️ Podcast", - to: "https://open.spotify.com/show/6oPJ7ZBlN7y34yiSMguIda", + to: "podcasts/", }, ], }, diff --git a/src/pages/podcasts/details.tsx b/src/pages/podcasts/details.tsx new file mode 100644 index 00000000..4101c5e4 --- /dev/null +++ b/src/pages/podcasts/details.tsx @@ -0,0 +1,105 @@ +import React from 'react'; +import Layout from '@theme/Layout'; +import type { ReactElement } from 'react'; +import { useLocation } from '@docusaurus/router'; +import './index.css'; + +interface PodcastData { + id: string; + spotifyUrl: string; + type: 'episode' | 'show' | 'playlist'; +} + +interface LocationState { + podcast: PodcastData; +} + +interface SpotifyTitleProps { + spotifyUrl: string; + type: 'episode' | 'show' | 'playlist'; +} + +// Fetches the podcast/show/episode title from Spotify oEmbed API +const SpotifyTitle: React.FC = ({ spotifyUrl, type }) => { + const [title, setTitle] = React.useState(''); + + React.useEffect(() => { + let cancelled = false; + fetch(`https://open.spotify.com/oembed?url=${encodeURIComponent(spotifyUrl)}`) + .then(res => res.json()) + .then(data => { + if (!cancelled) setTitle(data.title); + }) + .catch(() => { + if (!cancelled) setTitle(''); + }); + return () => { cancelled = true; }; + }, [spotifyUrl]); + return ( +
+ {title || (type.charAt(0).toUpperCase() + type.slice(1))} +
+ ); +}; + +export default function PodcastDetails(): ReactElement { + const location = useLocation(); + const state = location.state as LocationState; + const podcast = state?.podcast; + + // Random descriptive text about podcasts + const descriptions = [ + "Dive deep into fascinating conversations and thought-provoking content.", + "Experience the power of audio storytelling at its finest.", + "Join us on a journey of discovery through captivating discussions.", + "Explore new perspectives and expand your horizons.", + "Listen to expert insights and engaging narratives.", + "Uncover the stories behind the stories.", + "Get inspired by the voices that shape our world.", + "Tune in to the latest trends and timeless tales.", + "Discover the art of conversation and the beauty of sound.", + ]; + + // Get a random description + const randomDescription = descriptions[Math.floor(Math.random() * descriptions.length)]; + + if (!podcast) { + return ( + +
+

Podcast Not Found

+

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

+
+
+ ); + } + + return ( + +
+
+
+
+ +
+
+

{randomDescription}

+
+
+