-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpodcast-route.tsx
32 lines (28 loc) · 1.02 KB
/
podcast-route.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { type JSXHandler } from "revolution/jsx-runtime";
import { usePodcastEpisodes } from "../podcast/podcast.ts";
import { respondNotFound, useParams } from "revolution";
export function podcastRoute(): JSXHandler {
return function* () {
let { id } = yield* useParams<{ id: string }>();
let episodes = yield* usePodcastEpisodes();
let episode = episodes.find((episode) => episode.linkname === id);
if (!episode) {
return yield* respondNotFound();
}
let authors = episode.authors.collection.map(a => a.name).join(", ")
return (
<html>
<body>
<h1>{episode.title}</h1>
<ul>
<li><strong>description</strong>: {episode.description}</li>
<li><strong>image_url</strong>: {episode.image_url}</li>
<li><strong>duration</strong>: {episode.duration}</li>
<li><strong>audio</strong>: {episode.audio_file_url}</li>
<li><strong>authors</strong>: {authors}</li>
</ul>
</body>
</html>
);
};
}