2023-08-01 21:35:21 +02:00
|
|
|
import { Handlers, PageProps } from "$fresh/server.ts";
|
|
|
|
import { MainLayout } from "@components/layouts/main.tsx";
|
|
|
|
import { Article, getArticle } from "@lib/resource/articles.ts";
|
|
|
|
import { RecipeHero } from "@components/RecipeHero.tsx";
|
|
|
|
import { KMenu } from "@islands/KMenu.tsx";
|
2023-08-02 01:58:03 +02:00
|
|
|
import { isYoutubeLink, YoutubePlayer } from "@components/Youtube.tsx";
|
|
|
|
import { HashTags } from "@components/HashTags.tsx";
|
2023-08-01 21:35:21 +02:00
|
|
|
|
|
|
|
export const handler: Handlers<Article | null> = {
|
|
|
|
async GET(_, ctx) {
|
|
|
|
const movie = await getArticle(ctx.params.name);
|
|
|
|
return ctx.render(movie);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function Greet(props: PageProps<Article>) {
|
|
|
|
const article = props.data;
|
|
|
|
|
|
|
|
const { author = "", date = "" } = article.meta;
|
|
|
|
|
|
|
|
console.log({ tags: article.tags });
|
|
|
|
|
|
|
|
return (
|
|
|
|
<MainLayout url={props.url}>
|
|
|
|
<RecipeHero
|
|
|
|
data={article}
|
|
|
|
subline={[author, date.toString()]}
|
2023-08-02 01:58:03 +02:00
|
|
|
editLink={`https://notes.max-richter.dev/Media/articles/${article.id}`}
|
2023-08-01 21:35:21 +02:00
|
|
|
backlink="/articles"
|
|
|
|
/>
|
|
|
|
<KMenu type="main" context={article} />
|
2023-08-02 01:58:03 +02:00
|
|
|
{article.tags.length > 0 && (
|
|
|
|
<>
|
|
|
|
<br />
|
|
|
|
<HashTags tags={article.tags} />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
2023-08-01 21:35:21 +02:00
|
|
|
<div class="px-8 text-white mt-10">
|
2023-08-02 01:58:03 +02:00
|
|
|
{isYoutubeLink(article.meta.link) && (
|
|
|
|
<YoutubePlayer link={article.meta.link} />
|
|
|
|
)}
|
2023-08-01 21:35:21 +02:00
|
|
|
<pre
|
|
|
|
class="whitespace-break-spaces"
|
|
|
|
dangerouslySetInnerHTML={{ __html: article.content || "" }}
|
|
|
|
>
|
2023-08-02 01:58:03 +02:00
|
|
|
{article.content||""}
|
2023-08-01 21:35:21 +02:00
|
|
|
</pre>
|
|
|
|
</div>
|
|
|
|
</MainLayout>
|
|
|
|
);
|
|
|
|
}
|