Paginator

I want to sort the .Paginator by swapping matching types with a switch. Is there an intelligent way to do this? [or any way]

Here’s the switch (I mean if block):

{{$listPageTypes := slice}}
{{if eq .Type "about" }}
{{ else if (eq .Type "archives") }}
{{$listPageTypes = slice "archives"}}
{{ else if (eq .Type "motivation") }}
{{$listPageTypes = slice "motivation"}}
{{ else if (eq .Type "science") }}
{{$listPageTypes = slice "science"}}
{{ else if (eq .Type "categories") }}
{{$listPageTypes = slice "categories"}}
{{ else if (eq .Type "tags") }}
{{$listPageTypes = slice "tags"}}
{{ else if (eq .Type "books") }}
{{$listPageTypes = slice "books"}}
{{ else if (eq .Type "current") }}
{{$listPageTypes = slice "current"}}
{{ else if .IsHome}}
{{$listPageTypes = slice "archives" "books" "current" "motivation" "science" }}
{{else}}
{{end}}

here’s the paginator

{{ $paginator := .Paginate (where (where .Pages "Type" $listPageTypes).ByDate.Reverse "Params.hidden" "!=" true) 10 }}

The where clause of course doesn’t want to match “Type” with an array.

Also, an aside, where are the “Type” and other attributes of the .Pages stored? Or rather, how to look at them? When ranging through .Pages you just get the pages, not the meta data. Is there a function that prints everything associated with a variable?

Got it (but not the attribute display)

{{ $paginator := .Paginate (where (where .Site.RegularPages “Type” “in” $listPageTypes).ByDate.Reverse “Params.hidden” “!=” true) 10 }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.