88 lines
2.6 KiB
TypeScript
88 lines
2.6 KiB
TypeScript
import { PageProps, RouteContext } from "$fresh/server.ts";
|
|
import { MainLayout } from "@components/layouts/main.tsx";
|
|
import { getMovie, Movie } from "@lib/resource/movies.ts";
|
|
import { HashTags } from "@components/HashTags.tsx";
|
|
import { removeImage, renderMarkdown } from "@lib/documents.ts";
|
|
import { KMenu } from "@islands/KMenu.tsx";
|
|
import { RedirectSearchHandler } from "@islands/Search.tsx";
|
|
import { Recommendations } from "@islands/Recommendations.tsx";
|
|
import PageHero from "@components/PageHero.tsx";
|
|
import { Star } from "@components/Stars.tsx";
|
|
import { MetaTags } from "@components/MetaTags.tsx";
|
|
|
|
export default async function Greet(
|
|
props: PageProps<{ movie: Movie; session: Record<string, string> }>,
|
|
ctx: RouteContext,
|
|
) {
|
|
const movie = await getMovie(ctx.params.name);
|
|
const session = ctx.state.session;
|
|
|
|
if (!movie) {
|
|
return ctx.renderNotFound();
|
|
}
|
|
|
|
const { author = "", date = "" } = movie.meta;
|
|
|
|
const content = renderMarkdown(
|
|
removeImage(movie.description || "", movie.meta.image),
|
|
);
|
|
|
|
return (
|
|
<MainLayout url={props.url} title={`Movie > ${movie.name}`} context={movie}>
|
|
<RedirectSearchHandler />
|
|
<KMenu type="main" context={movie} />
|
|
<MetaTags resource={movie} />
|
|
<PageHero
|
|
image={movie.meta.image}
|
|
thumbnail={movie.meta.thumbnail}
|
|
>
|
|
<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>
|
|
{false && (
|
|
<Recommendations
|
|
id={movie.id}
|
|
type="movie"
|
|
/>
|
|
)}
|
|
{movie.tags.length > 0 && (
|
|
<>
|
|
<br />
|
|
<HashTags tags={movie.tags} />
|
|
</>
|
|
)}
|
|
<div class="px-8 text-white mt-10">
|
|
{movie?.description?.length > 80
|
|
? <h2 class="text-4xl font-bold mb-4">Review</h2>
|
|
: <></>}
|
|
<pre
|
|
class="whitespace-break-spaces"
|
|
dangerouslySetInnerHTML={{ __html: content || "" }}
|
|
>
|
|
{content}
|
|
</pre>
|
|
</div>
|
|
</MainLayout>
|
|
);
|
|
}
|