0.0.1 • Published 6 years ago
paginaator v0.0.1
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
0.0.1
6 years ago