Skip to content

Commit df6677f

Browse files
committed
Enable pagination
1 parent 47dad39 commit df6677f

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

_layouts/home.html

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
---
22
layout: default
3+
pagination:
4+
enabled: true
35
---
46

57
<div class="home">
8+
<!-- This is root index.html file, so no need to display title
69
{%- if page.title -%}
710
<h1 class="page-heading">{{ page.title }}</h1>
811
{%- endif -%}
12+
-->
913

1014
{{ content }}
1115

1216
{%- if site.posts.size > 0 -%}
1317
<h2 class="post-list-heading">{{ page.list_title | default: "Posts" }}</h2>
1418
<ul class="post-list">
15-
{%- for post in site.posts -%}
19+
{%- for post in paginator.posts -%}
1620
<li>
1721
{%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%}
1822
<span class="post-meta">{{ post.date | date: date_format }}</span>
@@ -28,6 +32,24 @@ <h3>
2832
{%- endfor -%}
2933
</ul>
3034

35+
<div class="pagination">
36+
{%- if paginator.previous_page %}
37+
<a href="{{ paginator.previous_page_path }}">Previous</a>
38+
{%- endif %}
39+
<!-- For pagination numbers if needed
40+
{%- for page in (1..paginator.total_pages) -%}
41+
{%- if page == paginator.page %}
42+
<span class="page-number current">{{ page }}</span>
43+
{%- else %}
44+
<a href="{{ paginator.page_path | replace: ':num', page }}" class="page-number">{{ page }}</a>
45+
{%- endif %}
46+
{%- endfor -%}
47+
-->
48+
49+
{%- if paginator.next_page %}
50+
<a href="{{ paginator.next_page_path }}">Next</a>
51+
{%- endif %}
52+
</div>
3153
{%- endif -%}
3254

3355
</div>

assets/css/style.css

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
.social-links {
88
display: flex;
9-
gap: 10px;
9+
gap: 20px;
1010
align-items: center;
1111
}
1212

@@ -27,3 +27,9 @@
2727
.intro-text {
2828
padding-top: 10px;
2929
}
30+
31+
.pagination {
32+
display: flex;
33+
gap: 10px;
34+
margin-top: 20px;
35+
}

index.html

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
layout: home
3+
title: "Home"
4+
pagination:
5+
enabled: true
6+
---

index.md

-6
This file was deleted.

0 commit comments

Comments
 (0)