webapp/src/pages/search.page.server.ts

18 lines
542 B
TypeScript
Raw Normal View History

2023-02-17 09:21:02 +00:00
import type { PageContext } from '../renderer/types'
2024-02-04 11:25:21 +00:00
import type { PageProps } from './types'
2023-11-28 13:18:25 +00:00
import { apiClient } from '../graphql/client/core'
2023-12-19 13:06:54 +00:00
import { SearchResult } from '../graphql/schema/core.gen'
2023-02-17 09:21:02 +00:00
export const onBeforeRender = async (pageContext: PageContext) => {
2023-11-29 12:37:27 +00:00
const { q: text } = pageContext.routeParams
2024-02-05 15:04:23 +00:00
const searchResults: SearchResult[] = await apiClient.getShoutsSearch({ text, limit: 50 })
const pageProps: PageProps = { searchResults, seo: { title: '' } }
2023-02-17 09:21:02 +00:00
return {
pageContext: {
pageProps,
},
2023-02-17 09:21:02 +00:00
}
}