import { Handlers, PageProps } from "$fresh/server.ts"; import { MainLayout } from "@components/layouts/main.tsx"; 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/markdown.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/marka/index.ts"; import { BookResource } from "@lib/marka/schema.ts"; import { parseRating } from "@lib/helpers.ts"; export const handler: Handlers<{ book: BookResource; session: unknown }> = { async GET(_, ctx) { const book = await fetchResource( `books/${ctx.params.name}.md`, ); if (!book) { return ctx.renderNotFound(); } return ctx.render({ book, session: ctx.state.session }); }, }; export default function Greet( props: PageProps< { book: BookResource; session: Record } >, ) { const { book, session } = props.data; const { author, datePublished, reviewRating, bookBody = "", reviewBody } = book?.content || {}; const bookContent = renderMarkdown( removeImage(bookBody, book.image?.url), ); const reviewContent = reviewBody ? renderMarkdown(removeImage(reviewBody, book.image?.url)) : undefined; const rating = reviewRating?.ratingValue && parseRating(reviewRating.ratingValue); return ( ${book.content.headline}`} context={book} > {session && ( )} {book.content.headline} {rating && } {book.content?.keywords?.length && ( <>
)}
{(book.content.url && isYoutubeLink(book.content.url)) && ( )}
        {reviewContent && (
          <>
            

Review

          
        )}
      
); }