import { useState, useEffect } from "react"; import type { ContentSegment } from "../../lib/parsing"; import type { PodcastEpisode } from "../../types/podcast"; import { resolveFountainEpisode } from "../../lib/podcast"; import { usePodcastStore } from "../../stores/podcast"; export function FountainCard({ seg }: { seg: ContentSegment }) { const [episode, setEpisode] = useState(null); const [loading, setLoading] = useState(true); const [failed, setFailed] = useState(false); const play = usePodcastStore((s) => s.play); useEffect(() => { resolveFountainEpisode(seg.value).then((ep) => { if (ep) setEpisode(ep); else setFailed(true); setLoading(false); }); }, [seg.value]); if (failed) { // Fallback: render as a regular link return (
F
Fountain.fm
{seg.value}
); } if (loading) { return (
); } if (!episode) return null; const handlePlay = (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); if (episode.enclosureUrl) { play(episode); } }; return (
{episode.artworkUrl ? ( { (e.target as HTMLImageElement).style.display = "none"; }} /> ) : (
F
)}
Fountain.fm
{episode.title}
{episode.showTitle && (
{episode.showTitle}
)}
{episode.enclosureUrl && ( )}
); }