Add pagination for list views
This commit is contained in:
parent
9474c646ca
commit
23434e2102
3 changed files with 13 additions and 6 deletions
|
@ -42,6 +42,7 @@ baseurl = "localhost"
|
||||||
title = "My Blog"
|
title = "My Blog"
|
||||||
languageCode = "en-us"
|
languageCode = "en-us"
|
||||||
theme = "hello-friend-ng"
|
theme = "hello-friend-ng"
|
||||||
|
paginate = 10
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
dateform = "Jan 2, 2006"
|
dateform = "Jan 2, 2006"
|
||||||
|
|
|
@ -8,6 +8,7 @@ theme = "hello-friend-ng"
|
||||||
PygmentsCodeFences = true
|
PygmentsCodeFences = true
|
||||||
PygmentsStyle = "monokai"
|
PygmentsStyle = "monokai"
|
||||||
|
|
||||||
|
paginate = 10
|
||||||
rssLimit = 10 # Maximum number of items in the RSS feed.
|
rssLimit = 10 # Maximum number of items in the RSS feed.
|
||||||
copyright = "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License." # This message is only used by the RSS template.
|
copyright = "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License." # This message is only used by the RSS template.
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
|
{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
|
||||||
|
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}
|
||||||
|
{{ $paginator := .Paginate (where .Site.RegularPages "Type" $contentTypeName) }}
|
||||||
|
|
||||||
<main class="posts">
|
<main class="posts">
|
||||||
<h1>{{ .Title }}</h1>
|
<h1>{{ .Title }}</h1>
|
||||||
|
|
||||||
{{- if .Content }}
|
{{ if .Content }}
|
||||||
<div class="content">{{ .Content }}</div>
|
<div class="content">{{ .Content }}</div>
|
||||||
{{- end }}
|
{{ end }}
|
||||||
|
|
||||||
{{- range .Data.Pages.GroupByDate "2006" }}
|
{{ range $paginator.Pages.GroupByDate "2006" }}
|
||||||
<div class="posts-group">
|
<div class="posts-group">
|
||||||
<div class="post-year">{{ .Key }}</div>
|
<div class="post-year">{{ .Key }}</div>
|
||||||
|
|
||||||
<ul class="posts-list">
|
<ul class="posts-list">
|
||||||
{{- range .Pages }}
|
{{ range .Pages }}
|
||||||
<li class="post-item">
|
<li class="post-item">
|
||||||
<a href="{{.Permalink}}">
|
<a href="{{.Permalink}}">
|
||||||
<span class="post-title">{{.Title}}</span>
|
<span class="post-title">{{.Title}}</span>
|
||||||
|
@ -24,9 +28,10 @@
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{- end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{{- end }}
|
{{ end }}
|
||||||
|
{{ partial "pagination.html" . }}
|
||||||
</main>
|
</main>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue