webapp/src/pages/author.page.server.ts
Untone fce0d7cfc6
Some checks are pending
deploy / test (push) Waiting to run
deploy / deploy (push) Blocked by required conditions
filter-format-fix
2023-11-29 15:37:27 +03:00

30 lines
756 B
TypeScript

import type { PageProps } from './types'
import type { PageContext } from '../renderer/types'
import { render } from 'vike/abort'
import { PRERENDERED_ARTICLES_COUNT } from '../components/Views/Author'
import { apiClient } from '../graphql/client/core'
export const onBeforeRender = async (pageContext: PageContext) => {
const { slug } = pageContext.routeParams
const author = await apiClient.getAuthor({ slug })
if (!author) {
throw render(404)
}
const authorShouts = await apiClient.getShouts({
filters: { author: slug, published: false },
limit: PRERENDERED_ARTICLES_COUNT,
})
const pageProps: PageProps = { author, authorShouts, seo: { title: author.name } }
return {
pageContext: {
pageProps,
},
}
}