2023-08-07 14:44:04 +02:00
|
|
|
import { Handlers, PageProps } from "$fresh/server.ts";
|
|
|
|
import { MainLayout } from "@components/layouts/main.tsx";
|
|
|
|
import { RecipeHero } from "@components/RecipeHero.tsx";
|
|
|
|
import { HashTags } from "@components/HashTags.tsx";
|
|
|
|
import { renderMarkdown } from "@lib/documents.ts";
|
|
|
|
import { getSeries, Series } from "@lib/resource/series.ts";
|
|
|
|
import { RedirectSearchHandler } from "@islands/Search.tsx";
|
|
|
|
import { KMenu } from "@islands/KMenu.tsx";
|
|
|
|
|
2023-08-12 18:32:56 +02:00
|
|
|
export const handler: Handlers<{ serie: Series; session: unknown }> = {
|
2023-08-07 14:44:04 +02:00
|
|
|
async GET(_, ctx) {
|
2023-08-09 15:47:37 +02:00
|
|
|
const serie = await getSeries(ctx.params.name);
|
|
|
|
return ctx.render({ serie, session: ctx.state.session });
|
2023-08-07 14:44:04 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-08-09 15:47:37 +02:00
|
|
|
export default function Greet(
|
|
|
|
props: PageProps<{ serie: Series; session: Record<string, string> }>,
|
|
|
|
) {
|
|
|
|
const { serie, session } = props.data;
|
2023-08-07 14:44:04 +02:00
|
|
|
|
|
|
|
const { author = "", date = "" } = serie.meta;
|
|
|
|
|
|
|
|
const content = renderMarkdown(serie.description || "");
|
|
|
|
|
|
|
|
return (
|
|
|
|
<MainLayout url={props.url} title={`Serie > ${serie.name}`} context={serie}>
|
|
|
|
<RedirectSearchHandler />
|
|
|
|
<KMenu type="main" context={serie} />
|
|
|
|
<RecipeHero
|
|
|
|
data={serie}
|
|
|
|
subline={[author, date.toString()]}
|
2023-08-09 15:47:37 +02:00
|
|
|
editLink={session
|
|
|
|
? `https://notes.max-richter.dev/Media/series/${serie.id}`
|
|
|
|
: ""}
|
2023-08-07 14:44:04 +02:00
|
|
|
backlink="/series"
|
|
|
|
/>
|
|
|
|
{serie.tags.length > 0 && (
|
|
|
|
<>
|
|
|
|
<br />
|
|
|
|
<HashTags tags={serie.tags} />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
<div class="px-8 text-white mt-10">
|
|
|
|
{serie?.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>
|
|
|
|
);
|
|
|
|
}
|