From 955af783007dde62fd3d9998c9b227ca91cbe735 Mon Sep 17 00:00:00 2001 From: Leon Mika Date: Wed, 2 Jul 2025 21:04:52 +1000 Subject: [PATCH] Extended options of 'order' --- layouts/shortcodes/postlist.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/layouts/shortcodes/postlist.html b/layouts/shortcodes/postlist.html index 6fe8111..ad372b1 100644 --- a/layouts/shortcodes/postlist.html +++ b/layouts/shortcodes/postlist.html @@ -5,9 +5,19 @@ {{- $pgr = (where $pgr "Params.categories" "intersect" (slice .)) -}} {{- end -}} {{- end -}} -{{- if (eq (.Get "order") "alpha" ) -}} - {{- $pgr = $pgr.ByLinkTitle -}} + +{{- if (ne (.Get "order") "") -}} + {{- $order := split (.Get "order") " " -}} + {{- if (eq (index $order 0) "alpha" ) -}} + {{- $pgr = $pgr.ByLinkTitle -}} + {{- else if (eq (index $order 0) "date" ) -}} + {{- $pgr = $pgr.ByDate -}} + {{- end -}} + {{- if (and (eq (len $order) 2) (eq (index $order 1) "desc")) -}} + {{- $pgr = $pgr.Reverse -}} + {{- end -}} {{- end -}} +