hugo-ataru

Hugo theme with titleless posts and microformats2 support

git clone git://git.shimmy1996.com/hugo-ataru.git
commit e7e9d0f3477389ad24866e7ed0ae69d01c5a06b6
parent 6bd29fbe344cec65115a4d6f88ab0df21fdd29d0
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Mon, 13 Apr 2020 09:50:29 -0500

Change pagination to sort posts in order, and default to the last page

Diffstat:
Mlayouts/_default/list.html | 4++--
Mlayouts/partials/nav_page.html | 12+++++++-----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
@@ -1,10 +1,10 @@
 {{ define "main" }}
 <main class="h-feed">
   {{ $pag := partial "get_paginator.html" . }}
-  {{ if (and .IsHome (not $pag.HasPrev)) }}
+  {{ if (not $pag.HasPrev) }}
   {{ .Content }}
   {{ end }}
-  {{ range $pag.Pages }}
+  {{ range $pag.Pages.ByDate }}
   <div class="h-entry">
     {{ partial "header.html" . }}
     <div class="e-content">{{ .Content }}</div>
diff --git a/layouts/partials/nav_page.html b/layouts/partials/nav_page.html
@@ -1,13 +1,15 @@
 {{ if .IsNode }}
 {{ $pag := partial "get_paginator.html" . }}
 <span style="float:right">
-  {{ if $pag.HasPrev }}<a href="{{ $pag.Prev.URL }}">↑</a>{{ else }}↑{{ end }}
-  {{ if $pag.HasNext }}<a href="{{ $pag.Next.URL }}">↓</a>{{ else }}↓{{ end }}
+  {{ if $pag.HasNext }}<a href="{{ $pag.Next.URL }}">↑</a>{{ else }}↑{{ end }}
+  {{ add 1 (sub $pag.TotalPages $pag.PageNumber) }}/{{ $pag.TotalPages }}
+  {{ if $pag.HasPrev }}<a href="{{ $pag.Prev.URL }}">↓</a>{{ else }}↓{{ end }}
 </span>
 {{ else }}
-{{ $pages := where .Site.RegularPages "Section" "==" .Section }}
 <span style="float:right">
-  {{with $pages.Next . }}<a href="{{ .RelPermalink }}">↑</a>{{ else }}↑{{end}}
-  {{with $pages.Prev . }}<a href="{{ .RelPermalink }}">↓</a>{{ else }}↓{{end}}
+  {{with .PrevInSection }}<a href="{{ .RelPermalink }}">↑</a>{{ else }}↑{{end}}
+  {{ $pages := where .Site.RegularPages "Section" "==" .Section }}
+  {{ len (where $pages ".Date" "le" $.Date) }}/{{ len $pages }}
+  {{with .NextInSection }}<a href="{{ .RelPermalink }}">↓</a>{{ else }}↓{{end}}
 </span>
 {{ end }}