Skip to content
Custom Handlebars Helper to improve how you paginate in Ghost
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
test
.gitignore
.npmignore
LICENSE
README.md
index.js
package.json
preview.jpg

README.md

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

You can’t perform that action at this time.