Skip to content

Commit ff87caf

Browse files
committed
wip(web): paginate blog archives with a centered numbered pager and 9 posts per page
1 parent 440f0f1 commit ff87caf

4 files changed

Lines changed: 63 additions & 0 deletions

File tree

‎web/config.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ ignoreFiles = ['_index\.template\.md$']
2222
tag = "tags"
2323
author = "author"
2424

25+
# blog archives render a 3-column card grid, so pages hold a multiple of 3
26+
[pagination]
27+
pagerSize = 9
28+
2529
[params]
2630
# draft site: keep search engines out — remove before production launch
2731
noindex = true

‎web/layouts/_default/list.html‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{ define "main" }}
2+
<section id="blog" class="sectionPad">
3+
<div class="gradientOverlay blueGradient inverted"></div>
4+
<div class="container">
5+
<div class="row">
6+
{{ if or .Title .Content }}
7+
<h1 class="col-sm-12 textGradient">{{ if ne .Section "blog" }} <span class="capitalize">{{ .Section }}:</span> {{ end }} {{ .Title }}</h1>
8+
{{ with .Content }}<div>{{ . }}</div>{{ end }}
9+
{{ end }}
10+
<div id="postList" class="row columnGap">
11+
{{ range .Paginator.Pages }}
12+
{{ .Render "summary" }}
13+
{{ end }}
14+
</div>
15+
{{ partial "pagination.html" . }}
16+
</div>
17+
</div>
18+
</section>
19+
{{ end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{ if gt .Paginator.TotalPages 1 }}
2+
<div class="separator"></div>
3+
<nav class="pagination textCenter">
4+
{{ if .Paginator.HasPrev }}
5+
<a href="{{ .Paginator.Prev.URL }}" class="prev noUnderline" title="Previous page">&lsaquo;</a>
6+
{{ end }}
7+
{{ range $i, $pager := .Paginator.Pagers }}
8+
{{- if $i }}<span class="dot">&middot;</span>{{ end -}}
9+
{{- if eq $pager.PageNumber $.Paginator.PageNumber -}}
10+
<span class="current">{{ $pager.PageNumber }}</span>
11+
{{- else -}}
12+
<a href="{{ $pager.URL }}" class="noUnderline" title="Page {{ $pager.PageNumber }}">{{ $pager.PageNumber }}</a>
13+
{{- end -}}
14+
{{ end }}
15+
{{ if .Paginator.HasNext }}
16+
<a href="{{ .Paginator.Next.URL }}" class="next noUnderline" title="Next page">&rsaquo;</a>
17+
{{ end }}
18+
</nav>
19+
{{ end }}

‎web/static/css/site.css‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,24 @@
4444
transform: rotate(225deg) translateY(-1px);
4545
}
4646
}
47+
48+
/* blog pagination (project partial): centered "< 1 · 2 · 3 > " pager */
49+
.pagination {
50+
/* relative lifts it above the section's absolutely-positioned
51+
.gradientOverlay, which otherwise swallows the clicks */
52+
position: relative;
53+
width: 100%;
54+
margin-top: 30px;
55+
}
56+
57+
.pagination a,
58+
.pagination .current,
59+
.pagination .dot {
60+
display: inline-block;
61+
padding: 0 10px;
62+
}
63+
64+
.pagination a {
65+
color: var(--baseColor);
66+
}
67+

0 commit comments

Comments
 (0)