memorium/routes/movies/[name].tsx

39 lines
1.0 KiB
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-31 04:19:04 +02:00
import { KMenu } from "@islands/KMenu.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
2023-07-31 17:21:17 +02:00
const { author = "", date = "" } = movie.meta;
2023-07-30 21:43:09 +02:00
return (
<MainLayout url={props.url}>
2023-07-31 17:21:17 +02:00
<RecipeHero
data={movie}
subline={[author, date.toString()]}
backlink="/movies"
/>
2023-07-31 04:19:04 +02:00
<KMenu type="main" context={movie} />
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>
);
}