feat: add series
This commit is contained in:
53
routes/series/[name].tsx
Normal file
53
routes/series/[name].tsx
Normal file
@ -0,0 +1,53 @@
|
||||
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";
|
||||
|
||||
export const handler: Handlers<Series | null> = {
|
||||
async GET(_, ctx) {
|
||||
const movie = await getSeries(ctx.params.name);
|
||||
return ctx.render(movie);
|
||||
},
|
||||
};
|
||||
|
||||
export default function Greet(props: PageProps<Series>) {
|
||||
const serie = props.data;
|
||||
|
||||
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()]}
|
||||
editLink={`https://notes.max-richter.dev/Media/series/${serie.id}`}
|
||||
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>
|
||||
);
|
||||
}
|
46
routes/series/index.tsx
Normal file
46
routes/series/index.tsx
Normal file
@ -0,0 +1,46 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import { Grid } from "@components/Grid.tsx";
|
||||
import { IconArrowLeft } from "@components/icons.tsx";
|
||||
import { getAllSeries, Series } from "@lib/resource/series.ts";
|
||||
import { Card } from "@components/Card.tsx";
|
||||
import { RedirectSearchHandler } from "@islands/Search.tsx";
|
||||
import { KMenu } from "@islands/KMenu.tsx";
|
||||
|
||||
export const handler: Handlers<Series[] | null> = {
|
||||
async GET(_, ctx) {
|
||||
const movies = await getAllSeries();
|
||||
return ctx.render(movies);
|
||||
},
|
||||
};
|
||||
|
||||
export default function Greet(props: PageProps<Series[] | null>) {
|
||||
return (
|
||||
<MainLayout url={props.url} title="Series" context={{ type: "series" }}>
|
||||
<RedirectSearchHandler />
|
||||
<KMenu type="main" context={{ type: "series" }} />
|
||||
<header class="flex gap-4 items-center mb-5 md:hidden">
|
||||
<a
|
||||
class="px-4 ml-4 py-2 bg-gray-300 text-gray-800 rounded-lg flex items-center gap-1"
|
||||
href="/"
|
||||
>
|
||||
<IconArrowLeft class="w-5 h-5" />
|
||||
Back
|
||||
</a>
|
||||
|
||||
<h3 class="text-2xl text-white font-light">🍿 Movies</h3>
|
||||
</header>
|
||||
<Grid>
|
||||
{props.data?.map((doc) => {
|
||||
return (
|
||||
<Card
|
||||
image={doc?.meta?.image || "/placeholder.svg"}
|
||||
link={`/series/${doc.id}`}
|
||||
title={doc.name}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</Grid>
|
||||
</MainLayout>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user