import htmlParse from 'html-react-parser' import { useReadingTime } from 'react-hook-reading-time' import { useRouteLoaderData } from 'react-router' import type { TTagResponse } from '~/apis/common/get-tags' import { ProfileIcon } from '~/components/icons/profile' import { Card } from '~/components/ui/card' import { CarouselSection } from '~/components/ui/carousel-section' import { IconsSocial } from '~/components/ui/social-share' import { BERITA } from '~/data/contents' import type { loader } from '~/routes/_news.detail.$slug' import { formatDate } from '~/utils/formatter' export const NewsDetailPage = () => { const loaderData = useRouteLoaderData( 'routes/_news.detail.$slug', ) const { newsDetailData } = loaderData || {} const { title, content, featured_image, slug, author, live_at, tags } = newsDetailData || {} const { text } = useReadingTime(content || '') return (

{title}

{/* START TODO: create component for this section */}
{author?.profile_picture ? ( {author?.name} ) : ( )}

{author?.name}

{live_at && `${formatDate(live_at)}`} ยท {text}

{/* END TODO: create component for this section */}
{title}
{content && htmlParse(content)}

Share this post

{tags?.map((tag: TTagResponse) => ( {tag.name} ))}
) }