
* WIP * WIP * lint * package-lock.json * test * test * meta tags fixed * dynamic titles fix --------- Co-authored-by: Igor Lobanov <igor.lobanov@onetwotrip.com>
22 lines
531 B
TypeScript
22 lines
531 B
TypeScript
import type { PageContext } from '../renderer/types'
|
|
import type { PageProps } from './types'
|
|
import { apiClient } from '../utils/apiClient'
|
|
import { render } from 'vike/abort'
|
|
|
|
export const onBeforeRender = async (pageContext: PageContext) => {
|
|
const { slug } = pageContext.routeParams
|
|
const article = await apiClient.getShoutBySlug(slug)
|
|
|
|
if (!article) {
|
|
throw render(404, '/404')
|
|
}
|
|
|
|
const pageProps: PageProps = { article, seo: { title: article.title } }
|
|
|
|
return {
|
|
pageContext: {
|
|
pageProps
|
|
}
|
|
}
|
|
}
|