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 15:56:33 +02:00
|
|
|
import { YoutubePlayer } from "@components/Youtube.tsx";
|
2023-08-02 01:58:03 +02:00
|
|
|
import { HashTags } from "@components/HashTags.tsx";
|
2023-08-02 15:56:33 +02:00
|
|
|
import { isYoutubeLink } from "@lib/string.ts";
|
2023-08-06 17:47:26 +02:00
|
|
|
import { renderMarkdown } from "@lib/documents.ts";
|
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;
|
|
|
|
|
2023-08-06 17:47:26 +02:00
|
|
|
const content = renderMarkdown(article.content);
|
|
|
|
|
2023-08-01 21:35:21 +02:00
|
|
|
return (
|
2023-08-06 18:06:09 +02:00
|
|
|
<MainLayout
|
|
|
|
url={props.url}
|
|
|
|
title={`Article > ${article.name}`}
|
|
|
|
context={article}
|
|
|
|
>
|
2023-08-01 21:35:21 +02:00
|
|
|
<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"
|
|
|
|
/>
|
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
|
2023-08-02 17:21:03 +02:00
|
|
|
class="whitespace-break-spaces markdown-body"
|
|
|
|
data-color-mode="dark"
|
|
|
|
data-dark-theme="dark"
|
2023-08-06 17:47:26 +02:00
|
|
|
dangerouslySetInnerHTML={{ __html: content || "" }}
|
2023-08-01 21:35:21 +02:00
|
|
|
>
|
2023-08-06 17:47:26 +02:00
|
|
|
{content||""}
|
2023-08-01 21:35:21 +02:00
|
|
|
</pre>
|
|
|
|
</div>
|
|
|
|
</MainLayout>
|
|
|
|
);
|
|
|
|
}
|