Skip to content

Commit 421aea0

Browse files
committed
Enable pagination at top and bottom of posts list
1 parent caecc2e commit 421aea0

4 files changed

Lines changed: 27 additions & 21 deletions

File tree

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Write an awesome description for your new site here. You can edit
55
baseurl: ""
66
url: "https://csswizardry.com"
77
future: true
8-
sw: "0017"
8+
sw: "0018"
99

1010
# Build settings
1111
markdown: kramdown

_includes/pagination.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<ol class="layout" data-ui-component="Pagination">
2+
3+
<li class="layout__item lap-and-up-one-half mb">
4+
{% if paginator.next_page %}
5+
<a href="/page{{paginator.next_page}}#section:articles" class="btn btn--full btn--secondary">Older articles</a>
6+
{% endif %}
7+
8+
{% if paginator.previous_page %}
9+
<li class="layout__item lap-and-up-one-half mb">
10+
{% if paginator.previous_page == 1 %}
11+
<a href="/#section:articles" class="btn btn--full">Newer articles</a>
12+
{% else %}
13+
<a href="/page{{paginator.previous_page}}#section:articles" class="btn btn--full">Newer articles</a>
14+
{% endif %}
15+
{% endif %}
16+
17+
</ol>
18+

index.html

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ <h3 class="heading">Articles</h3>
3030
<p>There are <b>{{ site.posts | size }}</b> articles on this blog.
3131
Find them all on the <a href="/archive/">archive page</a>.</p>
3232

33+
{% if paginator.page != 1 %}
34+
{% include pagination.html %}
35+
{% endif %}
36+
3337
<ul class="list-ui post__list mb">
3438
{% for post in paginator.posts %}
3539
<li class="list-ui__item">
@@ -39,25 +43,9 @@ <h3 class="post__title"><a href="{{ post.url }}">{{ post.title }}</a></h3>
3943
{% endfor %}
4044
</ul>
4145

42-
</section>
43-
44-
<ol class="layout" data-ui-component="Pagination">
46+
{% include pagination.html %}
4547

46-
<li class="layout__item lap-and-up-one-half mb">
47-
{% if paginator.next_page %}
48-
<a href="/page{{paginator.next_page}}#section:articles" class="btn btn--full btn--secondary">Older articles</a>
49-
{% endif %}
50-
51-
{% if paginator.previous_page %}
52-
<li class="layout__item lap-and-up-one-half mb">
53-
{% if paginator.previous_page == 1 %}
54-
<a href="/#section:articles" class="btn btn--full">Newer articles</a>
55-
{% else %}
56-
<a href="/page{{paginator.previous_page}}#section:articles" class="btn btn--full">Newer articles</a>
57-
{% endif %}
58-
{% endif %}
59-
60-
</ol>
48+
</section>
6149

6250
</div
6351

sw.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var cacheName = 'csswizardry:0017';
1+
var cacheName = 'csswizardry:0018';
22
var cacheFiles = [
33
'/',
44
'/about/',
@@ -53,7 +53,7 @@ self.addEventListener('fetch', function(event) {
5353
// Empty out any caches that don’t match the ones listed.
5454
self.addEventListener('activate', function(event) {
5555

56-
var cacheWhitelist = ['csswizardry:0017'];
56+
var cacheWhitelist = ['csswizardry:0018'];
5757

5858
event.waitUntil(
5959
caches.keys().then(function(cacheNames) {

0 commit comments

Comments
 (0)