Thanks for answer.
In my examples I was trying to get “true” value in any way.
What does “ge” mean? I can’t find it in documentation.
I think {{ if ge .Paginator.TotalPages 1 }} should work, but… I’m getting error:
ERROR 2017/06/28 16:19:04 Error while rendering “home”: template: theme/index.html:6:15: executing “theme/index.html” at <.Paginate>: error calling Paginate: a Paginator was previously built for this Node without filters; look for earlier .Paginator usage
In short my index.html looks like this (just an example):
<style>
{{ partial "style.css" . | safeCSS }}
</style>
<main>
{{ range ( .Paginate (where .Data.Pages "Type" "post")).Pages }}
<a href="{{ .Permalink }}"><h2>░ {{ .Title }}</h2></a>
<p>{{ .Params.description }}</p>
{{ end }}
</main>
<p class="pagination">
{{- if or (.Paginator.HasPrev) (.Paginator.HasNext) }}
{{- if .Paginator.HasPrev }}
<a class="newer" href="{{ .Paginator.Prev.URL }}">NEWER POSTS</a>
{{- end }}
{{- if .Paginator.HasNext }}
<a class="older" href="{{ .Paginator.Next.URL }}">OLDER POSTS</a>
{{- end }}
{{end}}
</p>
And my style.css looks like (just an example):
{{ if or (eq .Kind "home") (eq .Kind "taxonomy") }}
{{ if ge .Paginator.TotalPages 1 }}
.newer, .older {
border: 1px solid;
}
{{ end }}
{{ end }}
It seems I need different way to determine if page have pagination.
There are two ways to configure and use a .Paginator:
The simplest way is just to call .Paginator.Pages from a template. It will contain the pages for that page .
Select a sub-set of the pages with the available template functions and ordering options, and pass the slice to .Paginate, e.g. {{ range (.Paginate ( first 50 .Data.Pages.ByTitle )).Pages }}.
For a given Page, it’s one of the options above. The .Paginator is static and cannot change once created.
The problem is that, you are mixing them both. I think what you want is:
{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}
{{ range $paginator.Pages }}
<a href="{{ .Permalink }}"><h2>{{ .Title }}</h2></a>
<p>{{ .Params.description }}</p>
{{ end }}
/* ... replace every .Paginator with $paginator ... */
And about $paginator variable… here is another problem.
It seems it is impossible to access variables from partial files.
When I defined variable in html file, it was undefined in partial css file.
When I defined variable in partial css file, it was undefined in html file.