Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 170e8df

Browse files
committed
Implement ugly but functioning category post pagination
1 parent 34fe3e3 commit 170e8df

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

‎_layouts/post.html‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,34 @@ <h1 class="post-title">{{ page.title }}</h1>
88
<p class="post-meta">{{ page.date | date: "%b %-d, %Y" }}{% if page.author %} • {{ page.author }}{% endif %}{% if page.meta %} • {{ page.meta }}{% endif %}</p>
99
</header>
1010

11+
{% if page.categories %}
12+
{% assign category = page.categories[0] %}
13+
{% assign posts = site.categories[category] %}
14+
{% for post in posts %}
15+
{% if post.url == page.url %}
16+
{% assign post_index0 = forloop.index0 %}
17+
{% assign post_index1 = forloop.index %}
18+
{% endif %}
19+
{% endfor %}
20+
{% for post in posts %}
21+
{% if post_index0 == forloop.index %}
22+
{% assign next_post = post %}
23+
{% endif %}
24+
{% if post_index1 == forloop.index0 %}
25+
{% assign prev_post = post %}
26+
{% endif %}
27+
{% endfor %}
28+
{% endif %}
29+
30+
<div class="post-category-navigation">
31+
{% if prev_post != nil %}
32+
<a class="prev" href="{{ prev_post.url }}">&laquo; {{ prev_post.title }}</a>
33+
{% endif %}
34+
{% if next_post != nil %}
35+
<a class="next" href="{{ next_post.url }}">{{ next_post.title }} &raquo;</a>
36+
{% endif %}
37+
</div>
38+
1139
<article class="post-content" style="margin-bottom: 0px">
1240
{{ content }}
1341
</article>

‎_sass/_layout.scss‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* Some custom layout CSS
3+
*/
4+
.post-category-navigation {
5+
font-size: 14px;
6+
display: block;
7+
width: auto;
8+
overflow: hidden;
9+
}
10+
11+
.post-category-navigation a {
12+
display: block;
13+
width: 50%;
14+
float: left;
15+
margin: 1em 0;
16+
}
17+
18+
.post-category-navigation .next {
19+
text-align: right;
20+
}
121
/**
222
* Site header
323
*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /