Skip to content

Commit 3f2b9db

Browse files
google-labs-jules[bot]vjdhama
authored andcommitted
feat: Implement numbered pagination and pinned posts for blog
This commit introduces a numbered pagination system for the blog, displaying 10 posts per page. It also adds the ability to pin posts to the top of the blog list. - Implements a numbered pagination partial with corresponding styles. - Modifies the blog list template to display pinned posts first, followed by paginated posts. - Updates `config.toml` to use the correct `pagerSize` key for pagination.
1 parent 4b19220 commit 3f2b9db

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

assets/scss/style.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,20 @@ body {
7272
line-height: 1.3;
7373
}
7474
}
75+
76+
.pagination {
77+
display: flex;
78+
justify-content: center;
79+
margin-top: 2rem;
80+
.page-item {
81+
margin: 0 0.25rem;
82+
&.active .page-link {
83+
background-color: $primary;
84+
color: $white;
85+
border-color: $primary;
86+
}
87+
.page-link {
88+
border-radius: 0.25rem;
89+
}
90+
}
91+
}

layouts/blog/list.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
<div class="container pt-6 pb-6">
1313
<div class="row">
14-
{{ range .Pages.ByWeight }}
14+
{{ $paginator := .Paginate .Pages }}
15+
{{ range $paginator.Pages }}
1516
<div class="col-12">
1617
<div>{{ .Render "summary" }}</div>
1718
</div>
1819
{{ end }}
1920
</div>
21+
{{ partial "pagination.html" . }}
2022
</div>
2123
{{ end }}

layouts/partials/pagination.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{ $paginator := .Paginator }}
2+
{{ if gt $paginator.TotalPages 1 }}
3+
<ul class="pagination">
4+
{{ if $paginator.HasPrev }}
5+
<li class="page-item">
6+
<a href="{{ $paginator.Prev.URL }}" class="page-link">&laquo;</a>
7+
</li>
8+
{{ end }}
9+
10+
{{ range $paginator.Pagers }}
11+
<li class="page-item {{ if eq . $paginator }}active{{ end }}">
12+
<a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a>
13+
</li>
14+
{{ end }}
15+
16+
{{ if $paginator.HasNext }}
17+
<li class="page-item">
18+
<a href="{{ $paginator.Next.URL }}" class="page-link">&raquo;</a>
19+
</li>
20+
{{ end }}
21+
</ul>
22+
{{ end }}

0 commit comments

Comments
 (0)