0.1.3 • Published 8 years ago

ghost-pagination v0.1.3

Weekly downloads
26
License
MIT
Repository
github
Last release
8 years ago

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

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago