Hugo.exe v0.14
This is my current code. I get a three-page list.
{{ range first 3 .Data.Pages.ByDate }}
{{ if eq .Type "post"}}
<h1>{{ .Title }}</h1> {{ .Summary }}
{{ end }}
{{ end }}
But how can i get specific page by index number? For example just the second page?
Thanks in advance.
bep
#2
{{ index .Data.Pages.ByDate 1 }}
Will get you the second (0 indexed slice).
1 Like
Thanks a lot bep !
No i get the post by his index.
{{ with index .Data.Pages.ByDate 2 }}
{{ if eq .Type "post"}}
<h1>{{ .Title }}</h1> {{ .Summary }}
{{ end }}
{{ end }}
Great!
Sorting wasn’t stable. Now it seems working:
{{ with index (where .Data.Pages.ByDate.Reverse "Type" "post") 2 }}
<h1>{{ .Title }}</h1> {{ .Summary }}
{{ end }}