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' import type { TNews } from '~/types/news'
export const DUMMY_DESCRIPTION = 'Berita Terhangat hari ini'
export const SPOTLIGHT: TNews = { export const SPOTLIGHT: TNews = {
title: 'SPOTLIGHT', title: 'SPOTLIGHT',
description: 'Berita Terhangat hari ini', description: DUMMY_DESCRIPTION,
type: 'hero',
items: [ items: [
{ {
title: '01 Hotman Paris Membuka Perpustakaan di tengah Diskotik', title: '01 Hotman Paris Membuka Perpustakaan di tengah Diskotik',
@ -31,8 +32,7 @@ export const SPOTLIGHT: TNews = {
export const BERITA: TNews = { export const BERITA: TNews = {
title: 'BERITA', title: 'BERITA',
description: 'Berita Terhangat hari ini', description: DUMMY_DESCRIPTION,
type: 'grid',
items: [ items: [
{ {
title: '01 Travelling as a way of self-discovery and progress ', title: '01 Travelling as a way of self-discovery and progress ',
@ -89,8 +89,7 @@ export const BERITA: TNews = {
export const KAJIAN: TNews = { export const KAJIAN: TNews = {
title: 'KAJIAN', title: 'KAJIAN',
description: 'Berita Terhangat hari ini', description: DUMMY_DESCRIPTION,
type: 'grid',
items: [ items: [
{ {
title: 'Travelling as a way of self-discovery and progress', 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' import type { TNews } from '~/types/news'
export const BERITA: TNews = { export const BERITA: TNews = {
title: 'BERITA', title: 'BERITA',
description: 'Berita Terhangat hari ini', description: DUMMY_DESCRIPTION,
type: 'grid',
items: [ items: [
{ {
title: 'Travelling as a way of self-discovery and progress', 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 { Card } from '~/components/ui/card'
import { CategorySection } from '~/components/ui/category-section' import { CategorySection } from '~/components/ui/category-section'
import { DUMMY_DESCRIPTION } from '~/data/contents'
import type { loader } from '~/routes/_layout'
import { BERITA } from './data' import { BERITA } from './data'
export const NewsCategoriesPage = () => { 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 ( return (
<div className="relative"> <div className="relative">
<Card> <Card>
<CategorySection {...BERITA} /> <CategorySection
title={name || ''}
description={DUMMY_DESCRIPTION}
items={items}
/>
</Card> </Card>
</div> </div>
) )

View File

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

View File

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