Skip to content

Commit c26b8d8

Browse files
committed
Merge pull request sergiokopplin#6 from siddhantjain/gh-pages
Adding pagination in blog posts list
2 parents 5537cbf + 88b534d commit c26b8d8

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

_config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ email: myemail@gmail.com
1919

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

22+
#pagination
23+
paginate: 5
24+
paginate_path: "blog/page:num/"
25+
2226
gems:
2327
- jemoji
2428
- jekyll-mentions
2529
- jekyll-seo-tag
2630
- jekyll-feed
2731
- jekyll-sitemap
2832
- jekyll-gist
33+
- jekyll-paginate
2934

3035
jekyll-mentions:
3136
base_url: https://github.com

_includes/pagination.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="pagination">
2+
{% if paginator.previous_page %}
3+
<a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
4+
{% else %}
5+
<span class="previous">Previous</span>
6+
{% endif %}
7+
<span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
8+
{% if paginator.next_page %}
9+
<a href="{{ paginator.next_page_path }}" class="next">Next</a>
10+
{% else %}
11+
<span class="next ">Next</span>
12+
{% endif %}
13+
</div>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
layout: default
3-
permalink: /blog/index.html
43
title: Blog
54
---
65
{% include header.html %}
76

87
<section class="home__sections">
9-
{% for post in site.posts %}
8+
{% for post in paginator.posts %}
109
<div class="home__sections-single {% if post.star == true %}star{% endif %}">
1110
<a href="{{ site.url }}{{ post.url }}">
1211
<aside><time datetime="{{ post.date | date:"%d-%m-%Y" }}">{{ post.date | date: "%b %d %Y" }}</time></aside>
1312
<h3>{{ post.title }}</h3>
1413
</a>
1514
</div>
16-
{% endfor %}
15+
{% endfor %}
16+
{% include pagination.html%}
1717
</section>
1818

19-
{% include footer.html %}
19+
{% include footer.html %}

blog/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
layout: blog
3+
title: Blog
4+
---
5+
##Blog

0 commit comments

Comments
 (0)