From 94fc0df0b8fee0e55986983f2d9333a6ca068ce7 Mon Sep 17 00:00:00 2001 From: Geo Date: Tue, 22 Mar 2022 19:51:53 +0000 Subject: [PATCH] feat: add sort_by and sort_ascending options to Page Widget See #2666 --- wowchemy/layouts/partials/widgets/pages.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wowchemy/layouts/partials/widgets/pages.html b/wowchemy/layouts/partials/widgets/pages.html index 33e3c075..9423a030 100644 --- a/wowchemy/layouts/partials/widgets/pages.html +++ b/wowchemy/layouts/partials/widgets/pages.html @@ -12,7 +12,6 @@ {{ else }} {{ $items_count = $items_count | default 5 }} {{ end }} -{{ $items_sort := $st.Params.content.order | default "desc" }} {{/* Query */}} {{ $query := site.RegularPages }} @@ -59,8 +58,10 @@ {{ $count := len $query }} {{/* Sort */}} -{{ $sort_by := "Date" }} -{{ $query = sort $query $sort_by $items_sort }} +{{ $sort_by := $st.Params.content.sort_by | default "Date" }} +{{ $sort_ascending := $st.Params.content.sort_ascending | default (eq $st.Params.content.order "asc") | default false }} +{{ $sort_order := cond $sort_ascending "asc" "desc" }} +{{ $query = sort $query $sort_by $sort_order }} {{/* Offset and Limit */}} {{ if gt $items_offset 0 }}