dh_demo

DreamHanks demo project
git clone git://git.lair.cx/dh_demo
Log | Files | Refs | README

pagination.ts (334B)


      1 import { parseIntOrDefault } from '@/lib/utils/number'
      2 import { GetServerSidePropsContext } from 'next'
      3 
      4 export function getPageQuery (
      5   queries: GetServerSidePropsContext['query'],
      6   pageSize: number
      7 ) {
      8   const page = Math.max(parseIntOrDefault(queries.page, 1), 1)
      9   const offset = (page - 1) * pageSize
     10   return [page, offset]
     11 }