refactor: integrate autoplay functionality in Banner and enhance news data handling

This commit is contained in:
Ardeman
2025-03-09 14:32:04 +08:00
parent 550b16cfd3
commit e7eda086e4
5 changed files with 40 additions and 5 deletions
+17 -1
View File
@@ -6,17 +6,33 @@ import type { Route } from './+types/_news._index'
export const loader = async ({}: Route.LoaderArgs) => {
const { data: categoriesData } = await getCategories()
const spotlightCode = 'spotlight'
const spotlightCategory = categoriesData.find(
(category) => category.code === spotlightCode,
)
const { data: spotlightNews } = await getNews({ categories: [spotlightCode] })
const beritaCode = 'berita'
const beritaCategory = categoriesData.find(
(category) => category.code === 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 />