{{ $galleryTotal := len (where .Site.RegularPages "Section" "gallery") }} {{ $galleryReverse := (where .Site.RegularPages.Reverse "Section" "gallery") }} {{ if not (modBool $galleryTotal 2) }} {{ if eq $galleryTotal 1 }} {{ range first 3 $galleryReverse }}

{{ .Title }}

{{ if .Params.link1 }}

View

{{ end }} {{ if .Params.link2 }}

Code

{{ end }}
{{ end }} {{ end }} {{ if gt $galleryTotal 2 }} {{ range first 3 $galleryReverse }}

{{ .Title }}

{{ if .Params.link1 }}

View

{{ end }} {{ if .Params.link2 }}

Code

{{ end }}
{{ end }} {{ end }} {{ if gt $galleryTotal 3 }} {{ range after 3 $galleryReverse }} {{ $col := (mod $galleryTotal 3) }}

{{ .Title }}

{{ if .Params.link1 }}

View

{{ end }} {{ if .Params.link2 }}

Code

{{ end }}
{{ end }} {{ end }} {{ end }} {{ if modBool $galleryTotal 2 }} {{ range $galleryReverse }}

{{ .Title }}

{{ if .Params.link1 }}

View

{{ end }} {{ if .Params.link2 }}

Code

{{ end }}
{{ end }} {{ end }}