refactor: integrate autoplay functionality in Banner and enhance news data handling
This commit is contained in:
parent
550b16cfd3
commit
e7eda086e4
@ -1,10 +1,11 @@
|
|||||||
|
import Autoplay from 'embla-carousel-autoplay'
|
||||||
import useEmblaCarousel from 'embla-carousel-react'
|
import useEmblaCarousel from 'embla-carousel-react'
|
||||||
import { Link } from 'react-router'
|
import { Link } from 'react-router'
|
||||||
|
|
||||||
import { BANNER } from '~/data/contents'
|
import { BANNER } from '~/data/contents'
|
||||||
|
|
||||||
export const Banner = () => {
|
export const Banner = () => {
|
||||||
const [emblaReference] = useEmblaCarousel({ loop: false })
|
const [emblaReference] = useEmblaCarousel({ loop: true }, [Autoplay()])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
|
|||||||
@ -19,6 +19,11 @@ export const NewsPage = () => {
|
|||||||
description: loaderData?.beritaCategory?.description || '',
|
description: loaderData?.beritaCategory?.description || '',
|
||||||
items: loaderData?.beritaNews || [],
|
items: loaderData?.beritaNews || [],
|
||||||
}
|
}
|
||||||
|
const kajian: TNews = {
|
||||||
|
title: loaderData?.kajianCategory?.name || '',
|
||||||
|
description: loaderData?.kajianCategory?.description || '',
|
||||||
|
items: loaderData?.kajianNews || [],
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
@ -32,9 +37,9 @@ export const NewsPage = () => {
|
|||||||
<Card>
|
<Card>
|
||||||
<CarouselSection {...berita} />
|
<CarouselSection {...berita} />
|
||||||
</Card>
|
</Card>
|
||||||
{/* <Card>
|
<Card>
|
||||||
<CarouselSection {...KAJIAN} />
|
<CarouselSection {...kajian} />
|
||||||
</Card> */}
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,17 +6,33 @@ import type { Route } from './+types/_news._index'
|
|||||||
|
|
||||||
export const loader = async ({}: Route.LoaderArgs) => {
|
export const loader = async ({}: Route.LoaderArgs) => {
|
||||||
const { data: categoriesData } = await getCategories()
|
const { data: categoriesData } = await getCategories()
|
||||||
|
|
||||||
const spotlightCode = 'spotlight'
|
const spotlightCode = 'spotlight'
|
||||||
const spotlightCategory = categoriesData.find(
|
const spotlightCategory = categoriesData.find(
|
||||||
(category) => category.code === spotlightCode,
|
(category) => category.code === spotlightCode,
|
||||||
)
|
)
|
||||||
const { data: spotlightNews } = await getNews({ categories: [spotlightCode] })
|
const { data: spotlightNews } = await getNews({ categories: [spotlightCode] })
|
||||||
|
|
||||||
const beritaCode = 'berita'
|
const beritaCode = 'berita'
|
||||||
const beritaCategory = categoriesData.find(
|
const beritaCategory = categoriesData.find(
|
||||||
(category) => category.code === beritaCode,
|
(category) => category.code === beritaCode,
|
||||||
)
|
)
|
||||||
const { data: beritaNews } = await getNews({ categories: [beritaCode] })
|
const { data: beritaNews } = await getNews({ categories: [beritaCode] })
|
||||||
return { spotlightCategory, spotlightNews, beritaCategory, beritaNews }
|
|
||||||
|
const kajianCode = 'kajian'
|
||||||
|
const kajianCategory = categoriesData.find(
|
||||||
|
(category) => category.code === kajianCode,
|
||||||
|
)
|
||||||
|
const { data: kajianNews } = await getNews({ categories: [kajianCode] })
|
||||||
|
|
||||||
|
return {
|
||||||
|
spotlightCategory,
|
||||||
|
spotlightNews,
|
||||||
|
beritaCategory,
|
||||||
|
beritaNews,
|
||||||
|
kajianCategory,
|
||||||
|
kajianNews,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const NewsIndexLayout = () => <NewsPage />
|
const NewsIndexLayout = () => <NewsPage />
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"datatables.net-dt": "^2.2.2",
|
"datatables.net-dt": "^2.2.2",
|
||||||
"datatables.net-react": "^1.0.0",
|
"datatables.net-react": "^1.0.0",
|
||||||
|
"embla-carousel-autoplay": "^8.5.2",
|
||||||
"embla-carousel-react": "^8.5.2",
|
"embla-carousel-react": "^8.5.2",
|
||||||
"html-react-parser": "^5.2.2",
|
"html-react-parser": "^5.2.2",
|
||||||
"isbot": "^5.1.17",
|
"isbot": "^5.1.17",
|
||||||
|
|||||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@ -65,6 +65,9 @@ importers:
|
|||||||
datatables.net-react:
|
datatables.net-react:
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
embla-carousel-autoplay:
|
||||||
|
specifier: ^8.5.2
|
||||||
|
version: 8.5.2(embla-carousel@8.5.2)
|
||||||
embla-carousel-react:
|
embla-carousel-react:
|
||||||
specifier: ^8.5.2
|
specifier: ^8.5.2
|
||||||
version: 8.5.2(react@19.0.0)
|
version: 8.5.2(react@19.0.0)
|
||||||
@ -2331,6 +2334,11 @@ packages:
|
|||||||
electron-to-chromium@1.5.90:
|
electron-to-chromium@1.5.90:
|
||||||
resolution: {integrity: sha512-C3PN4aydfW91Natdyd449Kw+BzhLmof6tzy5W1pFC5SpQxVXT+oyiyOG9AgYYSN9OdA/ik3YkCrpwqI8ug5Tug==}
|
resolution: {integrity: sha512-C3PN4aydfW91Natdyd449Kw+BzhLmof6tzy5W1pFC5SpQxVXT+oyiyOG9AgYYSN9OdA/ik3YkCrpwqI8ug5Tug==}
|
||||||
|
|
||||||
|
embla-carousel-autoplay@8.5.2:
|
||||||
|
resolution: {integrity: sha512-27emJ0px3q/c0kCHCjwRrEbYcyYUPfGO3g5IBWF1i7714TTzE6L9P81V6PHLoSMAKJ1aHoT2e7YFOsuFKCbyag==}
|
||||||
|
peerDependencies:
|
||||||
|
embla-carousel: 8.5.2
|
||||||
|
|
||||||
embla-carousel-react@8.5.2:
|
embla-carousel-react@8.5.2:
|
||||||
resolution: {integrity: sha512-Tmx+uY3MqseIGdwp0ScyUuxpBgx5jX1f7od4Cm5mDwg/dptEiTKf9xp6tw0lZN2VA9JbnVMl/aikmbc53c6QFA==}
|
resolution: {integrity: sha512-Tmx+uY3MqseIGdwp0ScyUuxpBgx5jX1f7od4Cm5mDwg/dptEiTKf9xp6tw0lZN2VA9JbnVMl/aikmbc53c6QFA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@ -6990,6 +6998,10 @@ snapshots:
|
|||||||
|
|
||||||
electron-to-chromium@1.5.90: {}
|
electron-to-chromium@1.5.90: {}
|
||||||
|
|
||||||
|
embla-carousel-autoplay@8.5.2(embla-carousel@8.5.2):
|
||||||
|
dependencies:
|
||||||
|
embla-carousel: 8.5.2
|
||||||
|
|
||||||
embla-carousel-react@8.5.2(react@19.0.0):
|
embla-carousel-react@8.5.2(react@19.0.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
embla-carousel: 8.5.2
|
embla-carousel: 8.5.2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user