list-template: added ordering by weight

This commit is contained in:
Manjunath Mohan 2024-06-12 10:19:02 +05:30
parent afb206e5db
commit 6772f403d3

View file

@ -61,10 +61,13 @@
{{ $cardView := .Params.cardView | default (.Site.Params.list.cardView | default false) }} {{ $cardView := .Params.cardView | default (.Site.Params.list.cardView | default false) }}
{{ $cardViewScreenWidth := .Params.cardViewScreenWidth | default (.Site.Params.list.cardViewScreenWidth | default false) }} {{ $cardViewScreenWidth := .Params.cardViewScreenWidth | default (.Site.Params.list.cardViewScreenWidth | default false) }}
{{ $groupByYear := .Params.groupByYear | default ($.Site.Params.list.groupByYear | default false) }} {{ $groupByYear := .Params.groupByYear | default ($.Site.Params.list.groupByYear | default false) }}
{{ $orderByWeight := .Params.orderByWeight | default ($.Site.Params.list.orderByWeight | default false) }}
{{ $groupByYear := and (not $orderByWeight) $groupByYear }}
{{ if not $cardView }} {{ if not $cardView }}
<section class="space-y-10 w-full"> <section class="space-y-10 w-full">
{{ if not $orderByWeight }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
{{ if $groupByYear }} {{ if $groupByYear }}
<h2 class="mt-12 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300"> <h2 class="mt-12 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300">
@ -75,6 +78,11 @@
{{ partial "article-link/simple.html" . }} {{ partial "article-link/simple.html" . }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ else }}
{{ range (.Paginate (.Pages.ByWeight)).Pages }}
{{ partial "article-link/simple.html" . }}
{{ end }}
{{ end }}
</section> </section>
{{ else }} {{ else }}
@ -104,11 +112,17 @@
{{ else }} {{ else }}
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3"> <section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3">
{{ end }} {{ end }}
{{ if not $orderByWeight }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
{{ range .Pages }} {{ range .Pages }}
{{ partial "article-link/card.html" . }} {{ partial "article-link/card.html" . }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ else }}
{{ range (.Paginate (.Pages.ByWeight)).Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
{{ end }}
</section> </section>
{{ if $cardViewScreenWidth }} </div> {{ end }} {{ if $cardViewScreenWidth }} </div> {{ end }}