Skip to content

Commit

Permalink
Add pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Divyessh committed Sep 6, 2021
1 parent 9f9e188 commit 425bb79
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ GEM
terminal-table (~> 2.0)
jekyll-feed (0.15.1)
jekyll (>= 3.7, < 5.0)
jekyll-paginate-v2 (3.0.0)
jekyll (>= 3.0, < 5.0)
jekyll-sass-converter (2.1.0)
sassc (> 2.0.1, < 3.0)
jekyll-seo-tag (2.7.1)
jekyll (>= 3.8, < 5.0)
jekyll-sitemap (1.4.0)
jekyll (>= 3.7, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (2.3.1)
Expand Down Expand Up @@ -72,6 +76,8 @@ PLATFORMS
DEPENDENCIES
jekyll (~> 4.2.0)
jekyll-feed (~> 0.12)
jekyll-paginate-v2
jekyll-sitemap
minima (~> 2.5)
tzinfo (~> 1.2)
tzinfo-data
Expand Down
9 changes: 7 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ github_username: jekyll
# theme: minima
plugins:
- jekyll-feed
- jekyll-paginate-v2

defaults:
-
Expand All @@ -20,5 +21,9 @@ defaults:
layout: "post"
categories: jekyll update

paginate: 1
paginate_path: "/page:num/"
pagination:
enabled: true
per_page: 1
debug: true
permalink: '/:num'
category: 'posts'
19 changes: 18 additions & 1 deletion _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
<h3 style="text-align: center;">Events</h3>
</div>
<div class="event--list">
{% assign events = site.posts | sort: 'date' | reverse %}
{% assign events = paginator.posts | sort: 'date' | reverse %}
{% assign count = 0 %}
{% assign current_date = "now" | date: "%Y-%m-%d %H:%M" %}

Expand Down Expand Up @@ -204,6 +204,23 @@ <h3 class="event--header">{{ post.title }}</h3>
{% endfor %}

</div>
<div>
{% if paginator.total_pages > 1 %}
<ul>
{{paginator.previous_page}}
{% if paginator.previous_page!=nil %}
<li>
<a href="{{ paginator.previous_page_path | prepend: site.baseurl }}">Previous</a>
</li>
{% endif %}
{% if paginator.next_page!=nil %}
<li>
<a href="{{ paginator.next_page_path | prepend: site.baseurl }}">Next</a>
</li>
{% endif %}
</ul>
{% endif %}
</div>
</main>
<footer class="site-footer">
<p>
Expand Down

0 comments on commit 425bb79

Please sign in to comment.