refactor: update news types and enhance news data handling in components
This commit is contained in:
@@ -7,13 +7,18 @@ import { CarouselSection } from '~/components/ui/carousel-section'
|
||||
import { NewsAuthor } from '~/components/ui/news-author'
|
||||
import { SocialShareButtons } from '~/components/ui/social-share'
|
||||
import { Tags } from '~/components/ui/tags'
|
||||
import { BERITA } from '~/data/contents'
|
||||
import type { loader } from '~/routes/_news.detail.$slug'
|
||||
import type { TNews } from '~/types/news'
|
||||
|
||||
export const NewsDetailPage = () => {
|
||||
const loaderData = useRouteLoaderData<typeof loader>(
|
||||
'routes/_news.detail.$slug',
|
||||
)
|
||||
const berita: TNews = {
|
||||
title: loaderData?.beritaCategory?.name || '',
|
||||
description: loaderData?.beritaCategory?.description || '',
|
||||
items: loaderData?.beritaNews || [],
|
||||
}
|
||||
const currentUrl = globalThis.location
|
||||
const { title, content, featured_image, author, live_at, tags } =
|
||||
loaderData?.newsDetailData || {}
|
||||
@@ -69,7 +74,7 @@ export const NewsDetailPage = () => {
|
||||
</Card>
|
||||
|
||||
<Card className="bg-white p-5 max-sm:hidden">
|
||||
<CarouselSection {...BERITA} />
|
||||
<CarouselSection {...berita} />
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user