feat: sort categories by sequence and update category description handling in news pages
This commit is contained in:
parent
40a3553f9d
commit
87156e93ee
@ -7,7 +7,11 @@ import { HeaderSearch } from './header-search'
|
|||||||
|
|
||||||
export const HeaderMenu = () => {
|
export const HeaderMenu = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||||
const menu = loaderData?.categoriesData
|
const menu = loaderData?.categoriesData?.sort((a, b) => {
|
||||||
|
if (a.sequence === null) return 1
|
||||||
|
if (b.sequence === null) return -1
|
||||||
|
return a.sequence - b.sequence
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -1,18 +1,17 @@
|
|||||||
import { useLocation, useRouteLoaderData } from 'react-router'
|
import { useParams, 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/_news'
|
import type { loader } from '~/routes/_news'
|
||||||
|
|
||||||
import { BERITA } from './data'
|
import { BERITA } from './data'
|
||||||
|
|
||||||
export const NewsCategoriesPage = () => {
|
export const NewsCategoriesPage = () => {
|
||||||
const { pathname } = useLocation()
|
const parameters = useParams()
|
||||||
const code = pathname.split('/')[2]
|
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||||
const { name } =
|
const { name, description } =
|
||||||
loaderData?.categoriesData.find((item) => item.code === code) || {}
|
loaderData?.categoriesData.find((item) => item.code === parameters.code) ||
|
||||||
|
{}
|
||||||
const { items } = BERITA
|
const { items } = BERITA
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -20,7 +19,7 @@ export const NewsCategoriesPage = () => {
|
|||||||
<Card>
|
<Card>
|
||||||
<CategorySection
|
<CategorySection
|
||||||
title={name || ''}
|
title={name || ''}
|
||||||
description={DUMMY_DESCRIPTION}
|
description={description || ''}
|
||||||
items={items}
|
items={items}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user