2023-02-17 09:21:02 +00:00
|
|
|
import type { PageContext } from '../renderer/types'
|
|
|
|
import { apiClient } from '../utils/apiClient'
|
|
|
|
import type { PageProps } from './types'
|
2023-05-17 10:41:50 +00:00
|
|
|
import { PRERENDERED_ARTICLES_COUNT } from '../components/Views/Author/Author'
|
2023-02-17 09:21:02 +00:00
|
|
|
|
|
|
|
export const onBeforeRender = async (pageContext: PageContext) => {
|
|
|
|
const { slug } = pageContext.routeParams
|
|
|
|
|
|
|
|
const authorShouts = await apiClient.getShouts({
|
|
|
|
filters: { author: slug },
|
|
|
|
limit: PRERENDERED_ARTICLES_COUNT
|
|
|
|
})
|
|
|
|
const author = await apiClient.getAuthor({ slug })
|
|
|
|
|
|
|
|
const pageProps: PageProps = { author, authorShouts }
|
|
|
|
|
|
|
|
return {
|
|
|
|
pageContext: {
|
|
|
|
pageProps
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|