blob: bc7db67b0378a1ad33565cf23e30c74eec0621ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{{/*
Parameters:
- list: (Sections) or (Pages)
- params: (Params)
- scratch: (Scratch)
*/}}
{{/* Determine "order" & "reverse" */}}
{{ if eq (index .list 0).Kind "section" }}
{{ .scratch.Set "order" .Site.Params.projects.sections_order }}
{{ .scratch.Set "reverse" .Site.Params.projects.sections_order_reverse }}
{{ with .params.sections_order }}
{{ $.scratch.Set "order" . }}
{{ if $.params.sections_order_reverse }}
{{ $.scratch.Set "reverse" true }}
{{ else }}
{{ $.scratch.Set "reverse" false }}
{{ end }}
{{ end }}
{{ else }}
{{ .scratch.Set "order" .Site.Params.projects.posts_order }}
{{ .scratch.Set "reverse" .Site.Params.projects.posts_order_reverse }}
{{ with .params.posts_order }}
{{ $.scratch.Set "order" . }}
{{ if $.params.posts_order_reverse }}
{{ $.scratch.Set "reverse" true }}
{{ else }}
{{ $.scratch.Set "reverse" false }}
{{ end }}
{{ end }}
{{ end }}
{{/* Sort the list depneding on order */}}
{{ $order := .scratch.Get "order" }}
{{ if .scratch.Get "reverse" }}
{{ .scratch.Set "list" (.list.ByParam $order).Reverse }}
{{ else }}
{{ .scratch.Set "list" (.list.ByParam $order) }}
{{ end }}
{{ .scratch.Delete "order" }}
{{ .scratch.Delete "reverse" }}
|