feat: render description's html

chore: refactor to get episodes data from rss feed
This commit is contained in:
2024-04-20 16:58:52 +02:00
parent 8daddc383f
commit 730090ca9e
14 changed files with 1718 additions and 1351 deletions

View File

@@ -1,5 +1,5 @@
import { useParams } from "react-router-dom";
import { usePodcastEpisodesQuery } from "../services/podcasts/podcast.hooks";
import { usePodcastQuery } from "../services/podcasts/podcast.hooks";
export function Episode() {
const { podcastId, episodeId } = useParams<{
@@ -7,7 +7,7 @@ export function Episode() {
episodeId: string;
}>();
const { data: episodesData } = usePodcastEpisodesQuery(podcastId);
const { data: episodesData } = usePodcastQuery(podcastId);
const episode = episodesData?.episodes.find(
(episode) => episode.id.toString() === episodeId,
@@ -15,7 +15,10 @@ export function Episode() {
return (
<div>
<div>{episode?.description}</div>
<div
className={"prose"}
dangerouslySetInnerHTML={{ __html: episode?.description ?? "" }}
></div>
<div>
<audio controls src={episode?.audioUrl}>
Audio is not supported by your browser

View File

@@ -1,15 +1,11 @@
import { Outlet, useParams } from "react-router-dom";
import {
usePodcastEpisodesQuery,
useTopPodcastsQuery,
} from "../services/podcasts/podcast.hooks";
import { usePodcastQuery } from "../services/podcasts/podcast.hooks";
import { PodcastInfoCard } from "../components/podcast-info-card";
export function Podcast() {
const { podcastId } = useParams<{ podcastId: string }>();
const { data: podcasts } = useTopPodcastsQuery();
const { data: episodesData } = usePodcastEpisodesQuery(podcastId);
const { data: podcast } = usePodcastQuery(podcastId);
if (!podcastId) {
throw new Error(
@@ -17,12 +13,6 @@ export function Podcast() {
);
}
if (!podcasts) {
return null;
}
const podcast = podcasts.find((podcast) => podcast.id === podcastId);
if (!podcast) {
return <h1>Podcast not found</h1>;
}
@@ -33,7 +23,7 @@ export function Podcast() {
author={podcast.author}
title={podcast.title}
description={podcast.description}
imageURL={episodesData?.podcast.images.large ?? ""}
imageURL={podcast.images.large}
/>
<Outlet />
</div>