Skip to content

Commit 131191c

Browse files
committed
pagination with jekyll-paginate-v2
1 parent 0925619 commit 131191c

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ gem "minima", "~> 2.5"
99

1010
group :jekyll_plugins do
1111
gem "jekyll-feed", "~> 0.17"
12+
gem "jekyll-paginate-v2", "~> 3.0"
1213
end
1314

1415
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ GEM
6464
webrick (~> 1.7)
6565
jekyll-feed (0.17.0)
6666
jekyll (>= 3.7, < 5.0)
67+
jekyll-paginate-v2 (3.0.0)
68+
jekyll (>= 3.0, < 5.0)
6769
jekyll-sass-converter (3.1.0)
6870
sass-embedded (~> 1.75)
6971
jekyll-seo-tag (2.8.0)
@@ -138,6 +140,7 @@ DEPENDENCIES
138140
http_parser.rb (~> 0.6.0)
139141
jekyll (~> 4.4.1)
140142
jekyll-feed (~> 0.17)
143+
jekyll-paginate-v2 (~> 3.0)
141144
minima (~> 2.5)
142145
tzinfo (>= 1, < 3)
143146
tzinfo-data

_config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ google_analytics: GT-K4CTF7X
2525
theme: minima
2626
plugins:
2727
- jekyll-feed
28+
- jekyll-paginate-v2
2829

2930
include: ['_pages']
3031
permalink: pretty
@@ -35,6 +36,16 @@ defaults:
3536
values:
3637
permalink: /:categories/:year/:month/:title/
3738

39+
# See https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-GENERATOR.md
40+
pagination:
41+
enabled: true
42+
per_page: 6
43+
permalink: '/:num/'
44+
title: ':title — Page :num'
45+
sort_field: 'date'
46+
sort_reverse: true
47+
48+
3849
exclude:
3950
- README.md
4051
- LICENSE

_pages/news.html

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,37 @@
22
layout: page
33
title: "News"
44
permalink: /news/
5+
pagination:
6+
enabled: true
7+
category: News
58
---
69

710
<h2 class="wp-block-heading">Check out our recent news &amp; insights</h2>
811

912
<div class="wp-block-query is-layout-flow wp-block-query-is-layout-flow">
1013
<ul
1114
class="columns-3 wp-block-post-template is-layout-grid wp-container-core-post-template-is-layout-1 wp-block-post-template-is-layout-grid">
12-
{% for post in site.categories.News %}
15+
{% for post in paginator.posts %}
1316
<li
1417
class="wp-block-post post-350 post type-post status-publish format-standard has-post-thumbnail hentry category-news">
1518

1619
<div class="wp-block-group is-layout-flow wp-container-core-group-is-layout-7 wp-block-group-is-layout-flow"
1720
style="padding-top:20px;padding-right:20px;padding-bottom:20px;padding-left:20px">
21+
{% if post.featured_image %}
1822
<figure style="height:200px; margin-bottom:var(--wp--preset--spacing--small);"
19-
class="wp-block-post-featured-image"><a
20-
href="{{ post.url | relative_url }}" target="_self"
21-
style="height:200px"><img fetchpriority="high" decoding="async" width="1530" height="520"
23+
class="wp-block-post-featured-image"><a href="{{ post.url | relative_url }}" target="_self"
24+
style="height:200px"><img
2225
src="{{ post.featured_image | prepend: '/assets/images/' | relative_url }}"
2326
class="attachment-post-thumbnail size-post-thumbnail wp-post-image"
24-
alt="SpecFlow end-of-life has been announced" style="border-radius:5px;height:200px;object-fit:cover;"
25-
sizes="(max-width: 1530px) 100vw, 1530px"></a></figure>
27+
alt="{{ post.title }}" style="border-radius:5px;height:200px;object-fit:cover;"></a>
28+
</figure>
29+
{% else %}
30+
<div class="missing-image"></div>
31+
{% endif %}
2632

2733
<div class="taxonomy-category has-link-color wp-elements-82b5603708064b06546400967d8e01c5 wp-block-post-terms">
28-
<a href="{{ site.url }}/news/" rel="tag">News</a></div>
34+
<a href="{{ site.url }}/{{ post.categories | first | downcase }}/" rel="tag">{{post.categories | first}}</a>
35+
</div>
2936

3037
<h5 style="margin-bottom:var(--wp--preset--spacing--x-small);" class="wp-block-post-title"><a
3138
href="{{ post.url | relative_url }}" target="_self">{{ post.title }}</a></h5>
@@ -36,13 +43,31 @@ <h5 style="margin-bottom:var(--wp--preset--spacing--x-small);" class="wp-block-p
3643
<div class="wp-block-post-author-name has-x-small-font-size">{{ post.author }}</div>
3744

3845
<hr
39-
class="wp-block-separator has-text-color has-highlight-color has-alpha-channel-opacity has-highlight-background-color has-background is-style-default wp-container-content-3">
46+
class="wp-block-separator has-text-color has-highlight-color has-alpha-channel-opacity has-highlight-background-color has-background is-style-default wp-container-content-3">
4047

4148
<div class="wp-block-post-date">{{ post.date | date: "%B %-d, %Y" }}</div>
4249
</div>
4350
</div>
4451

4552
</li>
4653
{% endfor %}
47-
</ul>
54+
</ul>
4855
</div>
56+
57+
58+
{% if paginator.total_pages > 1 %}
59+
<ul>
60+
{% if paginator.previous_page %}
61+
<li>
62+
<a href="{{ paginator.previous_page_path | prepend: site.baseurl }}">&larr; Newer</a>
63+
</li>
64+
{% endif %}
65+
{% if paginator.next_page %}
66+
<li>
67+
<a href="{{ paginator.next_page_path | prepend: site.baseurl }}">Older &rarr;</a>
68+
</li>
69+
{% endif %}
70+
</ul>
71+
{% endif %}
72+
73+
<p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | relative_url }}">via RSS</a></p>

0 commit comments

Comments
 (0)