1
0
mirror of synced 2025-12-20 10:28:40 -05:00
Files
docs/components/hooks/usePage.ts
Peter Bengtsson 8765c628ff dedicated search results page (redux) (#29902)
* dedicated search results page (redux)

* Update SearchResults.tsx

* adding pagination

* fix pagination

* say something on NoQuery

* better Flash

* tidying link

* small fixes for results

* debug info

* l18n the meta info

* inDebugMode

* basic jest rendering of the skeleton page

* basic jest rendering test

* fix content tests

* better document title

* fix tests

* quote query in page title

* use home page sidebar

* something when nothing is found

* parseInt no longer needs the 10

* fix linting tests

* fix test

* prettier

* Update pages/search.tsx

Co-authored-by: Rachael Sewell <rachmari@github.com>

Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
Co-authored-by: Rachael Sewell <rachmari@github.com>
2022-08-19 13:36:55 +00:00

17 lines
351 B
TypeScript

import { useRouter } from 'next/router'
type Info = {
page: number
}
export const usePage = (): Info => {
const router = useRouter()
const page = parseInt(
router.query.page && Array.isArray(router.query.page)
? router.query.page[0]
: router.query.page || ''
)
return {
page: !isNaN(page) && page >= 1 ? page : 1,
}
}