ghost-pagination

0.1.3 • Public • Published

Ghost - Handlebars Pagination Helper

Custom Handlebars Helper to improve Pagination in Ghost. Based on Handlebars Paginate.

preview

##Install

npm install ghost-pagination

##Usage Ghost config.js

  /* ... */  
  var pagination = require('ghost-pagination');
  var hbs = require('express-hbs');
  /* ... */
  hbs.registerHelper('paginate', pagination);
  /* ... */  

partials/pagination.hbs

<div class="pagination center">
  <ul>      
      {{#paginate page pages limit="5"}}
          {{#if first}}
              <li {{#if active}} class="active" {{/if}}><a href="{{page_url n}}">{{n}}</a></li>
              {{#if ellipsis}}
                  <li class="pagination-ellipsis"><i class="material-icons">more_horiz</i></li>
              {{/if}}
          {{/if}}
          {{#if middle}}
              <li {{#if active}} class="active" {{/if}}><a href="{{page_url n}}">{{n}}</a></li>
          {{/if}}
          {{#if last}}
              {{#if ellipsis}}
                  <li class="pagination-ellipsis"><i class="material-icons">more_horiz</i></li>
              {{/if}}
              <li {{#if active}} class="active" {{/if}}><a href="{{page_url n}}">{{n}}</a></li>
          {{/if}}
      {{/paginate}}
  </ul>
</div>

Include limit attribute if you wish to restrict the number of pages, that appear between the first one and last one.

You can easily include previous and next links with Ghost built-in Pagination attributes. Refer to Handlebars Template Example.

License

MIT License

Package Sidebar

Install

npm i ghost-pagination

Weekly Downloads

0

Version

0.1.3

License

MIT

Last publish

Collaborators

  • danielr18