diff --git a/app/components/ui/carousel-section.tsx b/app/components/ui/carousel-section.tsx index d47a0d1..506f868 100644 --- a/app/components/ui/carousel-section.tsx +++ b/app/components/ui/carousel-section.tsx @@ -9,6 +9,8 @@ import type { loader } from '~/routes/_news' import type { TNews } from '~/types/news' import { getPremiumAttribute } from '~/utils/render' +import { Tags } from './tags' + export const CarouselSection = (properties: TNews) => { const { setIsSuccessOpen } = useNewsContext() const loaderData = useRouteLoaderData('routes/_news') @@ -89,21 +91,10 @@ export const CarouselSection = (properties: TNews) => { alt={title} />
-
- {tags?.map((item) => ( - - {item} - - ))} - {isPremium && ( - - Premium Content - - )} -
+

diff --git a/app/components/ui/category-section.tsx b/app/components/ui/category-section.tsx index e7f9f5a..3afaae1 100644 --- a/app/components/ui/category-section.tsx +++ b/app/components/ui/category-section.tsx @@ -10,6 +10,8 @@ import { useNewsContext } from '~/contexts/news' import type { loader } from '~/routes/_news' import { getPremiumAttribute } from '~/utils/render' +import { Tags } from './tags' + type TNews = { title: string description: string @@ -62,25 +64,10 @@ export const CategorySection = (properties: TNews) => { alt={title} />
-
- {tags?.map((item) => ( - - {item.name} - - ))} - {is_premium && ( - - Premium Content - - )} -
+

{ + const { tags, is_premium, className } = properties + return ( +
+ {tags?.map((tag) => ( + + {tag.name} + + ))} + {is_premium && ( + + Premium Content + + )} +
+ ) +} diff --git a/app/data/contents.ts b/app/data/contents.ts index 3e33c05..34e02d9 100644 --- a/app/data/contents.ts +++ b/app/data/contents.ts @@ -8,7 +8,7 @@ type TBanner = { createdAt?: string } -export const DUMMY_DESCRIPTION = 'Berita Terhangat hari ini' +const DUMMY_DESCRIPTION = 'Berita Terhangat hari ini' export const SPOTLIGHT: TNews = { title: 'SPOTLIGHT', @@ -47,7 +47,7 @@ export const BERITA: TNews = { content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', featured: '/images/news-2.jpg', - tags: ['Hukum Property'], + tags: [{ id: '1', code: 'hukum-property', name: 'Hukum Property' }], slug: 'travelling-as-a-way-of-self-discovery-and-progress', }, { @@ -55,7 +55,7 @@ export const BERITA: TNews = { content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', featured: '/images/news-3.jpg', - tags: ['Hukum'], + tags: [{ id: '2', code: 'hukum', name: 'Hukum' }], slug: 'how-does-writing-influence-your-personal-brand', }, { @@ -63,7 +63,7 @@ export const BERITA: TNews = { content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', featured: '/images/news-4.jpg', - tags: ['Hukum Property'], + tags: [{ id: '3', code: 'hukum-property', name: 'Hukum Property' }], isPremium: true, slug: 'helping-a-local-business-reinvent-itself', }, @@ -72,7 +72,7 @@ export const BERITA: TNews = { content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', featured: 'https://placehold.co/600x400.png', - tags: ['Hukum Property'], + tags: [{ id: '1', code: 'hukum-property', name: 'Hukum Property' }], slug: 'travelling-as-a-way-of-self-discovery-and-progress', }, { @@ -80,7 +80,7 @@ export const BERITA: TNews = { content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', featured: '/images/news-3.jpg', - tags: ['Hukum'], + tags: [{ id: '2', code: 'hukum', name: 'Hukum' }], slug: 'how-does-writing-influence-your-personal-brand', }, { @@ -88,7 +88,7 @@ export const BERITA: TNews = { content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', featured: '/images/news-4.jpg', - tags: ['Hukum Property'], + tags: [{ id: '3', code: 'hukum-property', name: 'Hukum Property' }], isPremium: true, slug: 'helping-a-local-business-reinvent-itself', }, diff --git a/app/pages/news-categories/data.ts b/app/pages/news-categories/data.ts deleted file mode 100644 index a640e10..0000000 --- a/app/pages/news-categories/data.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { DUMMY_DESCRIPTION } from '~/data/contents' -import type { TNews } from '~/types/news' - -export const BERITA: TNews = { - title: 'BERITA', - description: DUMMY_DESCRIPTION, - items: [ - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'Travelling as a way of self-discovery and progress', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-2.jpg', - tags: ['Hukum Property'], - slug: 'travelling-as-a-way-of-self-discovery-and-progress', - }, - { - title: 'How does writing influence your personal brand?', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-3.jpg', - tags: ['Hukum'], - slug: 'how-does-writing-influence-your-personal-brand', - }, - { - title: 'Helping a local business reinvent itself', - content: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros.', - featured: '/images/news-4.jpg', - tags: ['Hukum Property'], - isPremium: true, - slug: 'helping-a-local-business-reinvent-itself', - }, - ], -} diff --git a/app/pages/news-detail/index.tsx b/app/pages/news-detail/index.tsx index 6afe7a2..f91a02a 100644 --- a/app/pages/news-detail/index.tsx +++ b/app/pages/news-detail/index.tsx @@ -2,11 +2,11 @@ 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 { Card } from '~/components/ui/card' 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' @@ -62,16 +62,8 @@ export const NewsDetailPage = () => { title={`${title}`} />

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

diff --git a/app/types/news.ts b/app/types/news.ts index 32d2d5a..49e03ff 100644 --- a/app/types/news.ts +++ b/app/types/news.ts @@ -1,3 +1,5 @@ +import type { TTagResponse } from '~/apis/common/get-tags' + export type TNews = { title: string description: string @@ -14,7 +16,7 @@ type TNewsDetail = { author: string date: Date slug: string - tags?: Array + tags?: TTagResponse[] isPremium?: boolean categories?: Array }