refactor: enhance news handling and improve content display in various components
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
import { getNews } from '~/apis/common/get-news'
|
||||
import { handleCookie } from '~/libs/cookies'
|
||||
import { ContentsPage } from '~/pages/dashboard-contents'
|
||||
|
||||
import type { Route } from './+types/_admin.lg-admin._dashboard.contents._index'
|
||||
|
||||
export const loader = async ({ request }: Route.LoaderArgs) => {
|
||||
const { staffToken } = await handleCookie(request)
|
||||
const { data: newsData } = await getNews({
|
||||
accessToken: staffToken,
|
||||
})
|
||||
export const loader = async ({}: Route.LoaderArgs) => {
|
||||
const { data: newsData } = await getNews()
|
||||
return { newsData }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { getCategories } from '~/apis/common/get-categories'
|
||||
import { getNews } from '~/apis/common/get-news'
|
||||
import { APP } from '~/configs/meta'
|
||||
import { NewsCategoriesPage } from '~/pages/news-categories'
|
||||
|
||||
import type { Route } from './+types/_news.category.$code'
|
||||
@@ -8,7 +10,20 @@ export const loader = async ({ params }: Route.LoaderArgs) => {
|
||||
const categoryData = categoriesData.find(
|
||||
(category) => category.code === params.code,
|
||||
)
|
||||
return { categoryData }
|
||||
const { data: newsData } = await getNews({ categories: [params.code] })
|
||||
return { categoryData, newsData }
|
||||
}
|
||||
|
||||
export const meta = ({ data }: Route.MetaArgs) => {
|
||||
const { categoryData } = data
|
||||
const metaTitle = APP.title
|
||||
const title = `${categoryData?.name} - ${metaTitle}`
|
||||
|
||||
return [
|
||||
{
|
||||
title,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
const NewsCategoriesLayout = () => <NewsCategoriesPage />
|
||||
|
||||
Reference in New Issue
Block a user