memorium/routes/movies/[name].tsx

31 lines
871 B
TypeScript
Raw Normal View History

2023-07-30 21:43:09 +02:00
import { Handlers, PageProps } from "$fresh/server.ts";
import { MainLayout } from "@components/layouts/main.tsx";
2023-07-30 23:55:51 +02:00
import { Movie } from "@lib/movies.ts";
import { getMovie } from "../api/movies/[name].ts";
import { RecipeHero } from "@components/RecipeHero.tsx";
2023-07-30 21:43:09 +02:00
2023-07-30 23:55:51 +02:00
export const handler: Handlers<Movie | null> = {
2023-07-30 21:43:09 +02:00
async GET(_, ctx) {
2023-07-30 23:55:51 +02:00
const movie = await getMovie(ctx.params.name);
return ctx.render(movie);
2023-07-30 21:43:09 +02:00
},
};
2023-07-30 23:55:51 +02:00
export default function Greet(props: PageProps<Movie>) {
const movie = props.data;
2023-07-30 21:43:09 +02:00
return (
<MainLayout url={props.url}>
2023-07-30 23:55:51 +02:00
<RecipeHero data={movie} backlink="/movies" />
2023-07-30 21:43:09 +02:00
<div class="px-8 text-white mt-10">
<pre
class="whitespace-break-spaces"
2023-07-30 23:55:51 +02:00
dangerouslySetInnerHTML={{ __html: movie.description || "" }}
2023-07-30 21:43:09 +02:00
>
2023-07-30 23:55:51 +02:00
{movie.description}
2023-07-30 21:43:09 +02:00
</pre>
</div>
</MainLayout>
);
}