Skip to content

Commit

Permalink
Merge pull request barryclark#6 from siddhantjain/gh-pages
Browse files Browse the repository at this point in the history
Adding pagination in blog posts list
  • Loading branch information
sergiokopplin committed Feb 8, 2016
2 parents 5537cbf + 88b534d commit c26b8d8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ email: [email protected]

exclude: [README.md, Gemfile, Gemfile.lock, node_modules, gulpfile.js, package.json, _site, src, vendor]

#pagination
paginate: 5
paginate_path: "blog/page:num/"

gems:
- jemoji
- jekyll-mentions
- jekyll-seo-tag
- jekyll-feed
- jekyll-sitemap
- jekyll-gist
- jekyll-paginate

jekyll-mentions:
base_url: https://github.com
13 changes: 13 additions & 0 deletions _includes/pagination.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<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>
8 changes: 4 additions & 4 deletions blog.html → _layouts/blog.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
layout: default
permalink: /blog/index.html
title: Blog
---
{% include header.html %}

<section class="home__sections">
{% for post in site.posts %}
{% for post in paginator.posts %}
<div class="home__sections-single {% if post.star == true %}star{% endif %}">
<a href="{{ site.url }}{{ post.url }}">
<aside><time datetime="{{ post.date | date:"%d-%m-%Y" }}">{{ post.date | date: "%b %d %Y" }}</time></aside>
<h3>{{ post.title }}</h3>
</a>
</div>
{% endfor %}
{% endfor %}
{% include pagination.html%}
</section>

{% include footer.html %}
{% include footer.html %}
5 changes: 5 additions & 0 deletions blog/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: blog
title: Blog
---
##Blog

0 comments on commit c26b8d8

Please sign in to comment.