import { Handlers, PageProps } from "$fresh/server.ts"; import { MainLayout } from "@components/layouts/main.tsx"; import { Article } from "@lib/resource/articles.ts"; import { KMenu } from "@islands/KMenu.tsx"; import { YoutubePlayer } from "@components/Youtube.tsx"; import { HashTags } from "@components/HashTags.tsx"; import { isYoutubeLink } from "@lib/string.ts"; import { removeImage, renderMarkdown } from "@lib/documents.ts"; import { RedirectSearchHandler } from "@islands/Search.tsx"; import PageHero from "@components/PageHero.tsx"; import { Star } from "@components/Stars.tsx"; import { MetaTags } from "@components/MetaTags.tsx"; import { fetchResource } from "@lib/resources.ts"; export const handler: Handlers<{ article: Article; session: unknown }> = { async GET(_, ctx) { const article = await fetchResource(`articles/${ctx.params.name}.md`); if (!article) { return ctx.renderNotFound(); } return ctx.render({ article, session: ctx.state.session }); }, }; export default function Greet( props: PageProps<{ article: Article; session: Record }>, ) { const { article, session } = props.data; const { author = "", date = "", articleBody = "" } = article?.content || {}; const content = renderMarkdown( removeImage(articleBody, article.content.image), ); console.log({ article }); return ( ${article.content.headline}`} context={article} > {session && ( )} {article.content.headline} {article.content.rating && } {article.content?.tags?.length > 0 && ( <>
)}
{isYoutubeLink(article.content.url) && ( )}
          {content || ""}
        
); }