stacker.news/pages/search.js

24 lines
754 B
JavaScript
Raw Normal View History

2022-01-27 19:18:48 +00:00
import Layout from '../components/layout'
import { getGetServerSideProps } from '../api/ssrApollo'
import { ITEM_SEARCH } from '../fragments/items'
import SearchItems from '../components/search-items'
import { useRouter } from 'next/router'
2022-02-05 17:29:41 +00:00
import { SeoSearch } from '../components/seo'
2022-01-27 19:18:48 +00:00
export const getServerSideProps = getGetServerSideProps(ITEM_SEARCH)
2022-01-27 19:18:48 +00:00
export default function Index ({ data: { search: { items, cursor } } }) {
const router = useRouter()
2022-01-27 20:31:16 +00:00
2022-01-27 19:18:48 +00:00
return (
2022-02-05 17:29:41 +00:00
<Layout noSeo>
<SeoSearch />
{router.query?.q &&
<SearchItems
2022-10-20 22:44:44 +00:00
items={items} cursor={cursor}
variables={{ q: router.query?.q, sort: router.query?.sort, what: router.query?.what, when: router.query?.when }}
/>}
2022-01-27 19:18:48 +00:00
</Layout>
)
}