webapp/src/pages/author.page.server.ts
Kosta d90572e243
Fix/meta (#314)
* WIP

* WIP

* lint

* package-lock.json

* test

* test

* meta tags fixed

* dynamic titles fix

---------

Co-authored-by: Igor Lobanov <igor.lobanov@onetwotrip.com>
2023-11-14 12:45:44 +02:00

23 lines
674 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, seo: { title: author.name } }
return {
pageContext: {
pageProps
}
}
}