mirror of
https://github.com/ershisan99/podcaster.git
synced 2025-12-16 20:59:26 +00:00
feat: add page titles
This commit is contained in:
@@ -8,10 +8,12 @@ import {
|
|||||||
TableHeadCell,
|
TableHeadCell,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "./ui/table/table";
|
} from "./ui/table/table";
|
||||||
|
import { useTitle } from "../hooks/use-title";
|
||||||
|
|
||||||
export function PodcastEpisodesList() {
|
export function PodcastEpisodesList() {
|
||||||
const { podcastId } = useParams<{ podcastId: string }>();
|
const { podcastId } = useParams<{ podcastId: string }>();
|
||||||
const { data: podcast } = usePodcastQuery(podcastId);
|
const { data: podcast } = usePodcastQuery(podcastId);
|
||||||
|
useTitle(podcast?.title ?? "Podcast");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
11
src/hooks/use-title.ts
Normal file
11
src/hooks/use-title.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
export function useTitle(title: string) {
|
||||||
|
useEffect(() => {
|
||||||
|
const prevTitle = document.title;
|
||||||
|
document.title = title;
|
||||||
|
return () => {
|
||||||
|
document.title = prevTitle;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { usePodcastQuery } from "../services/podcasts/podcast.hooks";
|
import { usePodcastQuery } from "../services/podcasts/podcast.hooks";
|
||||||
|
import { useTitle } from "../hooks/use-title";
|
||||||
|
|
||||||
export function Episode() {
|
export function Episode() {
|
||||||
const { podcastId, episodeId } = useParams<{
|
const { podcastId, episodeId } = useParams<{
|
||||||
@@ -13,6 +14,8 @@ export function Episode() {
|
|||||||
(episode) => episode.id.toString() === episodeId,
|
(episode) => episode.id.toString() === episodeId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useTitle(episode?.title ?? "Episode");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"h-fit w-full p-4 pb-6 shadow-md"}>
|
<div className={"h-fit w-full p-4 pb-6 shadow-md"}>
|
||||||
<h2 className={"text-2xl font-bold tracking-tight"}>{episode?.title}</h2>
|
<h2 className={"text-2xl font-bold tracking-tight"}>{episode?.title}</h2>
|
||||||
|
|||||||
Reference in New Issue
Block a user