webapp/src/pages/search.page.server.ts
2024-02-05 18:04:23 +03:00

18 lines
542 B
TypeScript

import type { PageContext } from '../renderer/types'
import type { PageProps } from './types'
import { apiClient } from '../graphql/client/core'
import { SearchResult } from '../graphql/schema/core.gen'
export const onBeforeRender = async (pageContext: PageContext) => {
const { q: text } = pageContext.routeParams
const searchResults: SearchResult[] = await apiClient.getShoutsSearch({ text, limit: 50 })
const pageProps: PageProps = { searchResults, seo: { title: '' } }
return {
pageContext: {
pageProps,
},
}
}