zpager
a nodejs module render pagination html
install
npm install zpager --save
use
const Pager = let pager = var html = pager /* //html = <nav class="zpagenav" > <span class="pagination page-link m-r-1">total:100</span> <ul class="pagination"><li class="page-item disabled"> <span class="page-link" href="http://io.js?p=1" aria-label="Previous"><span aria-hidden="true">«</span><span class="sr-only">Previous</span></span> </li><li class="page-item active"> <a class="page-link" href="http://io.js?p=1" aria-label="1"><span>1</span></a> </li><li class="page-item "> <a class="page-link" href="http://io.js?p=2" aria-label="2"><span>2</span></a> </li><li class="page-item "> <a class="page-link" href="http://io.js?p=3" aria-label="3"><span>3</span></a> </li><li class="page-item "> <a class="page-link" href="http://io.js?p=4" aria-label="4"><span>4</span></a> </li><li class="page-item disabled"> <span class="page-link" href="http://io.js?p=1" aria-label="..."><span>...</span></span> </li><li class="page-item "> <a class="page-link" href="http://io.js?p=10" aria-label="10"><span>10</span></a> </li><li class="page-item "> <a class="page-link" href="http://io.js?p=2" aria-label="Next"><span aria-hidden="true">»</span><span class="sr-only">Next</span></a> </li></ul> </nav> */
customize
/** * constructor with option * * @param pageSize * @param total * @param pageSize * @param prevHtml * @param nextHtml * @param prevSrHtml * @param nextSrHtml * @param dotsHtml * @param template */ let option = pageSize: 10 total: 0 prevHtml: '«' nextHtml: '»' prevSrHtml: 'Previous' nextSrHtml: 'Next' dotsHtml: '...' { return `<nav class="zpagenav" > <span class="pagination page-link m-r-1">total:</span> <ul class="pagination">` + dataunits + `</ul> </nav>` } const Pager = let pager = optionvar html = pager
style it, for default template, just the same css from bootstrap4 pagination module
test
git clone https://github.com/zxdong262/pager.gitcd pagernpm installnpm i mocha -gmocha
License
MIT