Skip to content

jguyomard/jekyll-paginate-categories

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jekyll::Paginate::Categories

Default pagination generator for Jekyll Categories.

Installation

Add this line to your application's Gemfile:

gem 'jekyll-paginate-categories'

And then execute:

bundle

Or install it yourself as:

gem install jekyll-paginate-categories

Usage

Config example

Example of /_config.yml file:

# Pagination
paginate: 1
paginate_path: "/p/:num/"

paginate_category_basepath: '/c/:name/'
paginate_category_layout: 'category-test.html'

# Plugins
gems :
  - jekyll-paginate
  - jekyll-paginate-categories

Layout example

Example of /_layouts/categories.html file:

---
layout: default
---

<!-- Category title -->
<h1>Category: {{ page.category }}</h1>

<!-- This loops through the paginated posts -->
{% for post in paginator.posts %}
  <article>
    <header>
      <h1><a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a></h1>
    </header>
    <div class="entry-content">
      {{ post.excerpt }}
    </div>
  </article>
{% endfor %}

<!-- Pagination links -->
<div class="pagination">
  {% if paginator.previous_page %}
    <a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
  {% else %}
    <span class="previous">Previous</span>
  {% endif %}
  <span class="page_number">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
  {% if paginator.next_page %}
    <a href="{{ paginator.next_page_path }}" class="next">Next</a>
  {% else %}
    <span class="next">Next</span>
  {% endif %}
</div>

Credits

Inspired by this Nicolas Carlo's gist for Jekyll 1.5.1.

Contributing

Note: I'm not a Ruby developer, so feel free to improve my code by submiting a Github Pull Request.

You are invited to contribute new features, fixes or updates to this plugin, through a Github Pull Request.

Issues

If you have any problems with or questions about this plugin, please contact me through a GitHub issue.

Licence

MIT.

About

💎 Generate Pagination for Jekyll Categories.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages