Skip to content

jmmendivil/paginator-walker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paginator walker

Simple pages-numbers array generator.


Generates what pages numbers you should show, based on current page position and total pages, with custom threshold and number of pages to show.

With the default config params, from page 1 to page 4 generates [1, 2, 3, 4, 5], for page 5 it will walk and show [2, 3, 4, 5, 6]; if custom threshold config is in use, page 4 will start the walk [2, 3, 4, 5, 6] (threshold with value of 2).

Usage

const walker = require('pages-walker')
const currentPage = 1 // dynamic value from user
const totalPages = 10 // total pages from pagination
const pages = walker(currentPage, totalPages)

// pages -> [1,2,3,4,5] - 5 pages by default

Params

  • currentPage:1: Current page to calculate prev/next pages.
  • totalPages:5: Total pages from your pagination results.
  • Configuration:{ threshold: 1, showPages: 5 }: Configuration object for threshold and pages to generate.

About

Simple pages-numbers array generator.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published