2025-02-24 08:23:22 +08:00
|
|
|
import htmlParse from 'html-react-parser'
|
2025-03-08 00:14:30 +07:00
|
|
|
import { useRouteLoaderData } from 'react-router'
|
2025-02-24 08:23:22 +08:00
|
|
|
|
2025-03-08 00:14:30 +07:00
|
|
|
import type { TTagResponse } from '~/apis/common/get-tags'
|
2025-02-20 07:01:36 +08:00
|
|
|
import { Card } from '~/components/ui/card'
|
2025-02-28 18:55:12 +07:00
|
|
|
import { CarouselSection } from '~/components/ui/carousel-section'
|
2025-02-23 20:41:19 +07:00
|
|
|
import { IconsSocial } from '~/components/ui/social-share'
|
2025-03-02 12:15:31 +07:00
|
|
|
import { BERITA } from '~/data/contents'
|
2025-03-08 00:14:30 +07:00
|
|
|
import type { loader } from '~/routes/_news.detail.$slug'
|
|
|
|
|
import { formatDate } from '~/utils/formatter'
|
2025-02-20 07:01:36 +08:00
|
|
|
|
|
|
|
|
export const NewsDetailPage = () => {
|
2025-03-08 00:14:30 +07:00
|
|
|
const loaderData = useRouteLoaderData<typeof loader>(
|
|
|
|
|
'routes/_news.detail.$slug',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
const { newsDetailData }: any = loaderData
|
|
|
|
|
const { title, content, featured_image, slug, author, live_at, tags } =
|
|
|
|
|
newsDetailData
|
|
|
|
|
|
2025-02-20 07:01:36 +08:00
|
|
|
return (
|
2025-03-02 12:15:31 +07:00
|
|
|
<div className="sm-max:mx-5 relative">
|
2025-02-20 22:20:27 +07:00
|
|
|
<Card>
|
|
|
|
|
<div className="py-5 sm:px-30">
|
|
|
|
|
<h2 className="text-xl font-extrabold text-[#2E2F7C] sm:text-4xl">
|
|
|
|
|
{title}
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
{/* next planing create component for this section */}
|
2025-02-28 18:55:12 +07:00
|
|
|
<div className="my-5 w-full items-center justify-between gap-2 align-middle sm:flex">
|
|
|
|
|
<div className="mb-2 flex items-center gap-2 align-middle">
|
2025-02-20 22:20:27 +07:00
|
|
|
<img
|
|
|
|
|
src={'https://placehold.co/50x50.png'}
|
|
|
|
|
alt={title}
|
|
|
|
|
className="h-12 w-12 rounded-full"
|
|
|
|
|
/>
|
|
|
|
|
<div>
|
2025-03-08 00:14:30 +07:00
|
|
|
<h4 className="text-md">{author.name}</h4>
|
|
|
|
|
<p className="text-sm">{formatDate(live_at)} . 5 min read </p>
|
2025-02-20 22:20:27 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-03-06 22:49:56 +07:00
|
|
|
<IconsSocial className="flex-row" />
|
2025-02-20 22:20:27 +07:00
|
|
|
</div>
|
|
|
|
|
{/* end next planing create component for this section */}
|
|
|
|
|
<div className="w-full bg-amber-200">
|
|
|
|
|
<img
|
2025-03-08 00:14:30 +07:00
|
|
|
src={featured_image}
|
2025-02-20 22:20:27 +07:00
|
|
|
alt={title}
|
2025-02-28 18:55:12 +07:00
|
|
|
className="w-full object-cover object-center sm:h-[600px]"
|
2025-02-20 22:20:27 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-02-24 20:36:43 +07:00
|
|
|
<div className="mt-8 flex items-center justify-center">
|
|
|
|
|
<article className="prose prose-stone">
|
|
|
|
|
{htmlParse(content)}
|
|
|
|
|
</article>
|
|
|
|
|
</div>
|
2025-03-06 22:49:56 +07:00
|
|
|
<div className="items-end justify-between border-b-gray-300 py-4 sm:flex">
|
2025-02-28 18:55:12 +07:00
|
|
|
<div className="flex flex-col max-sm:mb-3">
|
2025-02-20 22:20:27 +07:00
|
|
|
<p className="mb-2">Share this post</p>
|
2025-03-08 00:14:30 +07:00
|
|
|
<IconsSocial
|
|
|
|
|
className="a"
|
|
|
|
|
slug={slug}
|
|
|
|
|
/>
|
2025-02-20 22:20:27 +07:00
|
|
|
</div>
|
2025-02-28 18:55:12 +07:00
|
|
|
<div className="flex flex-wrap items-end gap-2">
|
2025-03-08 00:14:30 +07:00
|
|
|
{tags?.map((tag: TTagResponse) => (
|
2025-02-20 22:20:27 +07:00
|
|
|
<span
|
2025-03-08 00:14:30 +07:00
|
|
|
key={tag.id}
|
2025-02-28 18:55:12 +07:00
|
|
|
className="rounded bg-gray-300 p-1"
|
2025-02-20 22:20:27 +07:00
|
|
|
>
|
2025-03-08 00:14:30 +07:00
|
|
|
{tag.name}
|
2025-02-20 22:20:27 +07:00
|
|
|
</span>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
|
2025-03-02 12:15:31 +07:00
|
|
|
<Card className="bg-white p-5 max-sm:hidden">
|
2025-02-28 18:55:12 +07:00
|
|
|
<CarouselSection {...BERITA} />
|
2025-02-20 07:01:36 +08:00
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|