Fix pagination on writeups

alternate-navbar
Maik de Kruif 3 years ago
parent d6544b95cf
commit 7178e45413
Signed by: maik
GPG Key ID: 44A55AD1F0673FA6
  1. 0
      .hugo_build.lock
  2. 1
      themes/maik-blog/layouts/_default/baseof.html
  3. 9
      themes/maik-blog/layouts/partials/seo.html
  4. 11
      themes/maik-blog/layouts/writeups/list.html

@ -1,3 +1,4 @@
{{- $paginator := .Paginate .RegularPagesRecursive }}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ .Site.Language }}"> <html lang="{{ .Site.Language }}">

@ -210,16 +210,15 @@
{{- end }} {{- end }}
{{- end }} {{- end }}
"description": {{ .Params.description | plainify }} "description": {{ .Params.description | plainify }}
}{{ end }}{{ if .IsSection }}, }{{ end }}{{ if or .IsSection (or (eq .Kind "term") (eq .Kind "taxonomy")) }},
{ {
"@context": "http://schema.org", "@context": "http://schema.org",
"@type": "ItemList", "@type": "ItemList",
"itemListOrder": "https://schema.org/ItemListOrderDescending", "itemListOrder": "https://schema.org/ItemListOrderDescending",
"name": "{{ .Title }}", "name": "{{ .Title }}",
"numberOfItems": {{ len .Data.Pages }}, "numberOfItems": {{ .Paginator.TotalNumberOfElements }},
"itemListElement": [ "itemListElement": [
{{- $pages := first 10 .Data.Pages }} {{- range $index, $page := .Paginator.Pages }}
{{- range $index, $page := $pages }}
{ {
"@type": "ListItem", "@type": "ListItem",
"position": {{ add $index 1 }}, "position": {{ add $index 1 }},
@ -283,7 +282,7 @@
{{- end }} {{- end }}
"description": {{ .Params.description | plainify }} "description": {{ .Params.description | plainify }}
} }
}{{ if ne (sub (len $pages) 1) $index }},{{ end }} }{{ if ne $index (sub $.Paginator.NumberOfElements 1) }},{{ end }}
{{- end }} {{- end }}
] ]
}{{ end }} }{{ end }}

@ -1,14 +1,5 @@
{{ define "main" }} {{ define "main" }}
{{- $allWriteups := slice }}
{{- range where (where .Site.Pages "Section" .Section) "IsPage" true }}
{{- if $.IsAncestor . }}
{{- $allWriteups = $allWriteups | append . }}
{{- end }}
{{- end }}
{{- $allWriteups = sort $allWriteups "Date" "desc" }}
{{ $paginator := .Paginate $allWriteups }}
<main class="posts"> <main class="posts">
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
@ -21,7 +12,7 @@
{{- end }} {{- end }}
<div class="posts-list masonry"> <div class="posts-list masonry">
{{ range $paginator.Pages }} {{ range .Paginator.Pages }}
<div class="post masonry-item"> <div class="post masonry-item">
<div class="masonry-item-content"> <div class="masonry-item-content">
<h2 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h2> <h2 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h2>

Loading…
Cancel
Save