webapp/src/pages/article.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

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
}
}
}