paginaator

0.0.1 • Public • Published

paginator.js

Tiny, smart pagination generator

Example

For an exhaustive list see snapshots.

Vanilla JS or JSX or whatever you want! Works in browser and Node.js. There are a lot of ways to do the following, this is just one...

import paginaator from 'paginaator';

const pages = paginaator({
  current: parseInt(getQueryParam("currentPage"), 10) || 1,
  totalPages: 10,
  render: v => isNaN(v) ? `<span>${v}</span>` : `<a href="?currentPage=${v}">${v}</a>`
});

console.info(pages);
// ['<a href="?currentPage=1">1</a>', '<a href="?currentPage=2>2</a>', '<a href="?currentPage=3">3</a>', '<span>...</span>', '<a href="?currentPage=10">10</a>'] 

Options

current :: Integer :: required
totalPages :: Integer :: required
render :: Function :: optional

Readme

Keywords

none

Package Sidebar

Install

npm i paginaator

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

26.1 kB

Total Files

8

Last publish

Collaborators

  • aef