memorium/routes/movies/[name].tsx

49 lines
1.4 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-08-01 17:50:00 +02:00
import { getMovie, Movie } from "@lib/resource/movies.ts";
2023-07-30 23:55:51 +02:00
import { RecipeHero } from "@components/RecipeHero.tsx";
2023-07-31 04:19:04 +02:00
import { KMenu } from "@islands/KMenu.tsx";
2023-08-02 01:58:03 +02:00
import { HashTags } from "@components/HashTags.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 (
2023-08-04 22:38:09 +02:00
<MainLayout url={props.url} title={`Movie > ${movie.name}`}>
2023-07-31 17:21:17 +02:00
<RecipeHero
data={movie}
subline={[author, date.toString()]}
editLink={`https://notes.max-richter.dev/Media/movies/${movie.id}`}
2023-07-31 17:21:17 +02:00
backlink="/movies"
/>
2023-07-31 04:19:04 +02:00
<KMenu type="main" context={movie} />
2023-08-02 01:58:03 +02:00
{movie.tags.length > 0 && (
<>
<br />
<HashTags tags={movie.tags} />
</>
)}
2023-07-30 21:43:09 +02:00
<div class="px-8 text-white mt-10">
2023-08-04 13:48:12 +02:00
{movie?.description?.length > 80
? <h2 class="text-4xl font-bold mb-4">Review</h2>
: <></>}
2023-07-30 21:43:09 +02:00
<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>
);
}