chore: refactor to take advantage of routing instead of rendering the same component twice

This commit is contained in:
2024-04-20 11:51:05 +02:00
parent 172e9e4c10
commit 2126e6bdbc
6 changed files with 96 additions and 53 deletions

View File

@@ -2,6 +2,7 @@ import { createBrowserRouter, RouterProvider } from "react-router-dom";
import { Home } from "./pages/home";
import { Podcast } from "./pages/podcast";
import { Episode } from "./pages/episode";
import { PodcastEpisodesList } from "./components/podcast-episodes-list";
const router = createBrowserRouter([
{
@@ -9,12 +10,18 @@ const router = createBrowserRouter([
element: <Home />,
},
{
path: "/podcast/:podcastId",
path: "/podcast",
element: <Podcast />,
},
{
path: "/podcast/:podcastId/episode/:episodeId",
element: <Episode />,
children: [
{
path: ":podcastId",
element: <PodcastEpisodesList />,
},
{
path: ":podcastId/episode/:episodeId",
element: <Episode />,
},
],
},
]);