refactor: replace hardcoded descriptions with a constant for consistency

This commit is contained in:
Ardeman 2025-03-02 12:37:19 +08:00
parent 3937cc673a
commit 20fa80370b
5 changed files with 25 additions and 12 deletions

View File

@ -1,9 +1,10 @@
import type { TNews } from '~/types/news'
export const DUMMY_DESCRIPTION = 'Berita Terhangat hari ini'
export const SPOTLIGHT: TNews = {
title: 'SPOTLIGHT',
description: 'Berita Terhangat hari ini',
type: 'hero',
description: DUMMY_DESCRIPTION,
items: [
{
title: '01 Hotman Paris Membuka Perpustakaan di tengah Diskotik',
@ -31,8 +32,7 @@ export const SPOTLIGHT: TNews = {
export const BERITA: TNews = {
title: 'BERITA',
description: 'Berita Terhangat hari ini',
type: 'grid',
description: DUMMY_DESCRIPTION,
items: [
{
title: '01 Travelling as a way of self-discovery and progress ',
@ -89,8 +89,7 @@ export const BERITA: TNews = {
export const KAJIAN: TNews = {
title: 'KAJIAN',
description: 'Berita Terhangat hari ini',
type: 'grid',
description: DUMMY_DESCRIPTION,
items: [
{
title: 'Travelling as a way of self-discovery and progress',

View File

@ -1,9 +1,9 @@
import { DUMMY_DESCRIPTION } from '~/data/contents'
import type { TNews } from '~/types/news'
export const BERITA: TNews = {
title: 'BERITA',
description: 'Berita Terhangat hari ini',
type: 'grid',
description: DUMMY_DESCRIPTION,
items: [
{
title: 'Travelling as a way of self-discovery and progress',

View File

@ -1,13 +1,28 @@
import { useLocation, useRouteLoaderData } from 'react-router'
import { Card } from '~/components/ui/card'
import { CategorySection } from '~/components/ui/category-section'
import { DUMMY_DESCRIPTION } from '~/data/contents'
import type { loader } from '~/routes/_layout'
import { BERITA } from './data'
export const NewsCategoriesPage = () => {
const { pathname } = useLocation()
const code = pathname.split('/')[2]
const loaderData = useRouteLoaderData<typeof loader>('routes/_layout')
const { name } =
loaderData?.categoriesData.find((item) => item.code === code) || {}
const { items } = BERITA
return (
<div className="relative">
<Card>
<CategorySection {...BERITA} />
<CategorySection
title={name || ''}
description={DUMMY_DESCRIPTION}
items={items}
/>
</Card>
</div>
)

View File

@ -1,3 +1,4 @@
import { DUMMY_DESCRIPTION } from '~/data/contents'
import type { TNews, TNewsDetail } from '~/types/news'
export const CONTENT: TNewsDetail = {
@ -40,8 +41,7 @@ export const CONTENT: TNewsDetail = {
export const BERITA: TNews = {
title: 'BERITA',
description: 'Berita Terhangat hari ini',
type: 'grid',
description: DUMMY_DESCRIPTION,
items: [
{
title: 'Travelling as a way of self-discovery and progress',

View File

@ -1,7 +1,6 @@
export type TNews = {
title: string
description: string
type: 'hero' | 'grid'
items: Pick<
TNewsDetail,
'title' | 'content' | 'featured' | 'slug' | 'tags' | 'isPremium'