memorium/routes/movies/[name].tsx

82 lines
2.5 KiB
TypeScript
Raw Normal View History

2023-10-16 01:40:10 +02:00
import { PageProps, RouteContext } from "$fresh/server.ts";
2023-07-30 21:43:09 +02:00
import { MainLayout } from "@components/layouts/main.tsx";
2023-08-01 17:50:00 +02:00
import { getMovie, Movie } from "@lib/resource/movies.ts";
2023-08-02 01:58:03 +02:00
import { HashTags } from "@components/HashTags.tsx";
2023-08-06 17:47:26 +02:00
import { renderMarkdown } from "@lib/documents.ts";
2023-08-07 14:44:04 +02:00
import { KMenu } from "@islands/KMenu.tsx";
import { RedirectSearchHandler } from "@islands/Search.tsx";
import { Recommendations } from "@islands/Recommendations.tsx";
2023-10-16 01:40:10 +02:00
import PageHero from "@components/PageHero.tsx";
import { Star } from "@components/Stars.tsx";
2025-01-23 18:42:29 +01:00
import { MetaTags } from "@components/MetaTags.tsx";
2023-07-30 21:43:09 +02:00
2023-09-08 13:33:29 +02:00
export default async function Greet(
props: PageProps<{ movie: Movie; session: Record<string, string> }>,
2023-09-08 13:33:29 +02:00
ctx: RouteContext,
) {
2023-09-08 13:33:29 +02:00
const movie = await getMovie(ctx.params.name);
const session = ctx.state.session;
2023-07-30 21:43:09 +02:00
2023-07-31 17:21:17 +02:00
const { author = "", date = "" } = movie.meta;
2023-08-06 17:47:26 +02:00
const content = renderMarkdown(movie.description || "");
2023-07-30 21:43:09 +02:00
return (
2023-08-06 18:06:09 +02:00
<MainLayout url={props.url} title={`Movie > ${movie.name}`} context={movie}>
2023-08-07 14:44:04 +02:00
<RedirectSearchHandler />
<KMenu type="main" context={movie} />
2025-01-23 18:42:29 +01:00
<MetaTags resource={movie} />
<PageHero
image={movie.meta.image}
thumbnail={movie.meta.thumbnail}
>
2023-10-16 01:40:10 +02:00
<PageHero.Header>
<PageHero.BackLink href="/movies" />
{session && (
<PageHero.EditLink
href={`https://notes.max-richter.dev/Media/movies/${movie.id}`}
/>
)}
</PageHero.Header>
<PageHero.Footer>
<PageHero.Title>{movie.name}</PageHero.Title>
<PageHero.Subline
entries={[
author && {
title: author,
href: `/?q=${encodeURIComponent(author)}`,
},
date.toString(),
]}
>
{movie.meta.rating && <Star rating={movie.meta.rating} />}
</PageHero.Subline>
</PageHero.Footer>
</PageHero>
2025-01-19 21:11:38 +01:00
{false && (
<Recommendations
id={movie.id}
type="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-08-06 17:47:26 +02:00
dangerouslySetInnerHTML={{ __html: content || "" }}
2023-07-30 21:43:09 +02:00
>
2023-08-06 17:47:26 +02:00
{content}
2023-07-30 21:43:09 +02:00
</pre>
</div>
</MainLayout>
);
}