mirror of
https://github.com/acid-info/logos-press-engine.git
synced 2025-02-23 14:48:08 +00:00
fix: sort tags on landing page based on their number of posts
This commit is contained in:
parent
c492e68113
commit
2f7b5fdad0
@ -1,6 +1,6 @@
|
||||
import { Button, Typography } from '@acid-info/lsd-react'
|
||||
import styled from '@emotion/styled'
|
||||
import React from 'react'
|
||||
import React, { useMemo } from 'react'
|
||||
import { Grid, GridItem } from '../../components/Grid/Grid'
|
||||
import { Hero } from '../../components/Hero'
|
||||
import { PostsGrid } from '../../components/PostsGrid'
|
||||
@ -28,10 +28,17 @@ export type HomePageProps = React.DetailedHTMLProps<
|
||||
|
||||
export const HomePage: React.FC<HomePageProps> = ({
|
||||
data,
|
||||
data: { highlighted = [], shows = [], tags = [], latest },
|
||||
data: { highlighted = [], shows = [], tags: _tags = [], latest },
|
||||
...props
|
||||
}) => {
|
||||
const query = useRecentPosts({ initialData: latest, limit: 12 })
|
||||
const tags = useMemo(
|
||||
() =>
|
||||
_tags
|
||||
.filter((t) => !!t.postsCount && t.postsCount > 0)
|
||||
.sort((a, b) => (a.postsCount! > b.postsCount! ? -1 : 1)),
|
||||
[_tags],
|
||||
)
|
||||
|
||||
return (
|
||||
<Root {...props}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user