webapp/src/pages/allAuthors.page.server.ts

27 lines
769 B
TypeScript
Raw Normal View History

2023-02-17 09:21:02 +00:00
import type { PageContext } from '../renderer/types'
2024-02-04 11:25:21 +00:00
import type { PageProps } from './types'
2024-02-29 21:11:59 +00:00
import { PAGE_SIZE } from '../components/Views/AllTopics/AllTopics'
2023-11-28 13:18:25 +00:00
import { apiClient } from '../graphql/client/core'
2023-02-17 09:21:02 +00:00
export const onBeforeRender = async (_pageContext: PageContext) => {
2023-12-26 23:28:26 +00:00
const allAuthors = await apiClient.getAllAuthors()
2024-02-29 21:11:59 +00:00
const topWritingAuthors = await apiClient.loadAuthorsBy({
by: { order: 'shouts' },
limit: PAGE_SIZE,
offset: 0,
})
const topFollowedAuthors = await apiClient.loadAuthorsBy({
by: { order: 'followers' },
limit: PAGE_SIZE,
offset: 0,
})
2024-02-29 20:46:15 +00:00
const pageProps: PageProps = { allAuthors, seo: { title: '' }, topWritingAuthors, topFollowedAuthors }
2023-02-17 09:21:02 +00:00
return {
pageContext: {
pageProps,
},
2023-02-17 09:21:02 +00:00
}
}