Skip to content

Commit a38eb75

Browse files
committed
add pagination
1 parent f15edcd commit a38eb75

4 files changed

Lines changed: 38 additions & 6 deletions

File tree

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ pygments: true
44
markdown: redcarpet
55
url: http://wp-cli.org
66
permalink: /blog/:title.html
7+
paginate: 10
78
exclude:
89
- Phakefile.php

_includes/footer.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
</section>
22
</div>
3-
<footer>
4-
<div class="container">
5-
Initial code by <a href="https://github.com/andreascreten">Andreas Creten</a>. Project maintained by <a href="https://github.com/scribu">Cristi Burc&#259;</a>.
6-
</div>
7-
</footer>
3+
4+
<footer>Initial code by <a href="https://github.com/andreascreten">Andreas Creten</a>. Project maintained by <a href="https://github.com/scribu">Cristi Burc&#259;</a>.</footer>
85

96
{% include analytics.html %}
107
</body>

assets/css/stylesheet.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ header h2 {
7474
}
7575

7676
footer {
77+
clear: both;
78+
display: block;
7779
text-align: center;
7880
font-size: 10px;
7981
margin: 20px 10px 10px 10px;
@@ -279,3 +281,17 @@ article + article {
279281
color: #666;
280282
}
281283

284+
/* Pagination */
285+
286+
.pagination {
287+
display: block;
288+
overflow: hidden;
289+
}
290+
291+
.pagination .prev {
292+
float: left;
293+
}
294+
295+
.pagination .next {
296+
float: right;
297+
}

blog/index.html

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
title: Blog
44
---
55

6-
{% for post in site.posts limit: 10 %}
6+
{% for post in paginator.posts %}
77
<article>
88
<div class="post-header">
99
<h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
@@ -15,3 +15,21 @@ <h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
1515
</div>
1616
</article>
1717
{% endfor %}
18+
19+
<nav class="pagination">
20+
{% if paginator.previous_page %}
21+
<div class="prev">
22+
{% if paginator.previous_page == 1 %}
23+
<a href="/blog/">←&nbsp;&nbsp;&nbsp;Newer</a>
24+
{% else %}
25+
<a href="/blog/page{{paginator.previous_page}}">←&nbsp;&nbsp;&nbsp;Newer</a>
26+
{% endif %}
27+
</div>
28+
{% endif %}
29+
30+
{% if paginator.next_page %}
31+
<div class="next">
32+
<a href="/blog/page{{paginator.next_page}}">Older&nbsp;&nbsp;&nbsp;→</a>
33+
</div>
34+
{% endif %}
35+
</nav>

0 commit comments

Comments
 (0)