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

23 lines
674 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 } from '../components/Views/Author'
2023-02-17 09:21:02 +00:00
export const onBeforeRender = async (pageContext: PageContext) => {
const { slug } = pageContext.routeParams
const authorShouts = await apiClient.getShouts({
2023-10-25 13:57:21 +00:00
filters: { author: slug, visibility: 'community' },
2023-02-17 09:21:02 +00:00
limit: PRERENDERED_ARTICLES_COUNT
})
const author = await apiClient.getAuthor({ slug })
const pageProps: PageProps = { author, authorShouts, seo: { title: author.name } }
2023-02-17 09:21:02 +00:00
return {
pageContext: {
pageProps
}
}
}