diff --git a/src/components/Views/AllAuthors/AllAuthors.tsx b/src/components/Views/AllAuthors/AllAuthors.tsx index 3934a73d..9509b7bf 100644 --- a/src/components/Views/AllAuthors/AllAuthors.tsx +++ b/src/components/Views/AllAuthors/AllAuthors.tsx @@ -23,6 +23,8 @@ type AllAuthorsPageSearchParams = { type Props = { authors: Author[] + topFollowedAuthors?: Author[] + topWritingAuthors?: Author[] isLoaded: boolean } diff --git a/src/components/Views/AllTopics/AllTopics.tsx b/src/components/Views/AllTopics/AllTopics.tsx index 36548a33..3fe6243d 100644 --- a/src/components/Views/AllTopics/AllTopics.tsx +++ b/src/components/Views/AllTopics/AllTopics.tsx @@ -28,7 +28,7 @@ type Props = { isLoaded: boolean } -const PAGE_SIZE = 20 +export const PAGE_SIZE = 20 export const AllTopics = (props: Props) => { const { t, lang } = useLocalize() diff --git a/src/components/Views/Feed/Feed.tsx b/src/components/Views/Feed/Feed.tsx index 2a886a10..9f07159b 100644 --- a/src/components/Views/Feed/Feed.tsx +++ b/src/components/Views/Feed/Feed.tsx @@ -48,23 +48,11 @@ type VisibilityItem = { } type FeedSearchParams = { - by: 'publish_date' | 'likes_stat' | 'rating' | 'last_comment' + by: 'publish_date' | 'likes' | 'comments' period: FeedPeriod visibility: VisibilityMode } -const getOrderBy = (by: FeedSearchParams['by']) => { - if (by === 'likes_stat' || by === 'rating') { - return 'likes_stat' - } - - if (by === 'last_comment') { - return 'last_comment' - } - - return '' -} - const getFromDate = (period: FeedPeriod): number => { const now = new Date() let d: Date = now @@ -178,9 +166,8 @@ export const FeedView = (props: Props) => { offset: sortedArticles().length, } - const orderBy = getOrderBy(searchParams().by) - if (orderBy) { - options.order_by = orderBy + if (searchParams()?.by) { + options.order_by = searchParams().by } const visibilityMode = searchParams().visibility @@ -222,7 +209,7 @@ export const FeedView = (props: Props) => { const ogTitle = t('Feed') const [shareData, setShareData] = createSignal() - const handleShare = (shared) => { + const handleShare = (shared: Shout | undefined) => { showModal('share') setShareData(shared) } @@ -260,19 +247,19 @@ export const FeedView = (props: Props) => { {/**/}
  • - changeSearchParams({ by: 'rating' })}> + changeSearchParams({ by: 'likes' })}> {t('Top rated')}
  • - changeSearchParams({ by: 'last_comment' })}> + changeSearchParams({ by: 'comments' })}> {t('Most commented')}
  • diff --git a/src/pages/allAuthors.page.server.ts b/src/pages/allAuthors.page.server.ts index dcc8681b..5fbd4992 100644 --- a/src/pages/allAuthors.page.server.ts +++ b/src/pages/allAuthors.page.server.ts @@ -2,11 +2,13 @@ import type { PageContext } from '../renderer/types' import type { PageProps } from './types' import { apiClient } from '../graphql/client/core' +import { PAGE_SIZE } from "../components/Views/AllTopics/AllTopics"; export const onBeforeRender = async (_pageContext: PageContext) => { const allAuthors = await apiClient.getAllAuthors() - - const pageProps: PageProps = { allAuthors, seo: { title: '' } } + const topWritingAuthors = await apiClient.loadAuthorsBy({ by: { order: 'shouts' }, limit: PAGE_SIZE}) + const topFollowedAuthors = await apiClient.loadAuthorsBy({ by: { order: 'followers' }, limit: PAGE_SIZE}) + const pageProps: PageProps = { allAuthors, seo: { title: '' }, topWritingAuthors, topFollowedAuthors } return { pageContext: { diff --git a/src/pages/types.ts b/src/pages/types.ts index 96701c6c..af588d9f 100644 --- a/src/pages/types.ts +++ b/src/pages/types.ts @@ -10,6 +10,8 @@ export type PageProps = { homeShouts?: Shout[] author?: Author allAuthors?: Author[] + topWritingAuthors?: Author[] + topFollowedAuthors?: Author[] topic?: Topic allTopics?: Topic[] searchQuery?: string