webapp/src/pages/author.page.server.ts
2023-10-25 15:57:21 +02:00

23 lines
645 B
TypeScript

import type { PageContext } from '../renderer/types'
import { apiClient } from '../utils/apiClient'
import type { PageProps } from './types'
import { PRERENDERED_ARTICLES_COUNT } from '../components/Views/Author'
export const onBeforeRender = async (pageContext: PageContext) => {
const { slug } = pageContext.routeParams
const authorShouts = await apiClient.getShouts({
filters: { author: slug, visibility: 'community' },
limit: PRERENDERED_ARTICLES_COUNT
})
const author = await apiClient.getAuthor({ slug })
const pageProps: PageProps = { author, authorShouts }
return {
pageContext: {
pageProps
}
}
}