1
Fork 0

Customize ordering on list pages

This commit is contained in:
Jake Howard 2017-09-15 08:44:12 +01:00
parent 600c813bfb
commit a617ad961c
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 4 additions and 21 deletions

View file

@ -2,4 +2,6 @@
title: Blog title: Blog
linktitle: Posts linktitle: Posts
show_images: true show_images: true
sort_by: Date
sort_order: desc
--- ---

View file

@ -4,7 +4,8 @@
{{ if ne .Params.hide_pages "true" }} {{ if ne .Params.hide_pages "true" }}
<div class="row"> <div class="row">
{{ $parent := . }} {{ $parent := . }}
{{ $valid_pages := where .Site.Pages.ByTitle ".Parent" "!=" nil }} {{ $sorted_pages := sort .Site.Pages (default "Title" .Params.sort_by) (default "asc" .Params.sort_order)}}
{{ $valid_pages := where $sorted_pages ".Parent" "!=" nil }}
{{ $valid_pages := where $valid_pages ".Params.hide_in_list" "!=" "true" }} {{ $valid_pages := where $valid_pages ".Params.hide_in_list" "!=" "true" }}
{{ range where $valid_pages ".Parent.UniqueID" $parent.UniqueID }} {{ range where $valid_pages ".Parent.UniqueID" $parent.UniqueID }}
{{ if $parent.Params.show_images }} {{ if $parent.Params.show_images }}

View file

@ -1,20 +0,0 @@
{{ partial "page_start.html" . }}
<section id="main" class="container">
{{ partial "content.html" . }}
{{ if ne .Params.hide_pages "true" }}
<div class="row">
{{ $parent := . }}
{{ $valid_pages := sort .Site.Pages "Date" "desc" }}
{{ $valid_pages := where $valid_pages ".Parent" "!=" nil }}
{{ $valid_pages := where $valid_pages ".Params.hide_in_list" "!=" "true" }}
{{ range where $valid_pages ".Parent.UniqueID" $parent.UniqueID }}
{{ if $parent.Params.show_images }}
{{ partial "box_image.html" . }}
{{ else }}
{{ partial "box.html" . }}
{{ end }}
{{ end }}
</div>
{{ end }}
</section>
{{ partial "page_end.html" . }}