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

21 lines
641 B
TypeScript
Raw Normal View History

2023-02-17 09:21:02 +00:00
import type { PageContext } from '../renderer/types'
import { apiClient } from '../utils/apiClient'
import type { PageProps } from './types'
import { PRERENDERED_ARTICLES_COUNT, RANDOM_TOPICS_COUNT } from '../components/Views/Home'
export const onBeforeRender = async (_pageContext: PageContext) => {
const randomTopics = await apiClient.getRandomTopics({ amount: RANDOM_TOPICS_COUNT })
const homeShouts = await apiClient.getShouts({
filters: { visibility: 'public' },
limit: PRERENDERED_ARTICLES_COUNT
})
const pageProps: PageProps = { randomTopics, homeShouts }
return {
pageContext: {
pageProps
}
}
}