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 { Button, Typography } from '@acid-info/lsd-react'
|
||||||
import styled from '@emotion/styled'
|
import styled from '@emotion/styled'
|
||||||
import React from 'react'
|
import React, { useMemo } from 'react'
|
||||||
import { Grid, GridItem } from '../../components/Grid/Grid'
|
import { Grid, GridItem } from '../../components/Grid/Grid'
|
||||||
import { Hero } from '../../components/Hero'
|
import { Hero } from '../../components/Hero'
|
||||||
import { PostsGrid } from '../../components/PostsGrid'
|
import { PostsGrid } from '../../components/PostsGrid'
|
||||||
|
@ -28,10 +28,17 @@ export type HomePageProps = React.DetailedHTMLProps<
|
||||||
|
|
||||||
export const HomePage: React.FC<HomePageProps> = ({
|
export const HomePage: React.FC<HomePageProps> = ({
|
||||||
data,
|
data,
|
||||||
data: { highlighted = [], shows = [], tags = [], latest },
|
data: { highlighted = [], shows = [], tags: _tags = [], latest },
|
||||||
...props
|
...props
|
||||||
}) => {
|
}) => {
|
||||||
const query = useRecentPosts({ initialData: latest, limit: 12 })
|
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 (
|
return (
|
||||||
<Root {...props}>
|
<Root {...props}>
|
||||||
|
|
Loading…
Reference in New Issue