blob: e2899d3a92ff5aff9ade078aa2fd7ff42b25be8e (
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
|
{{/*
Parameters:
- type: "tags" or "categories"
- context: (.)
- scratch: (Scratch)
- removeDuplicates: BOOL
*/}}
{{/* Get all the "tags" or "categories" from a page (and its descendents) */}}
{{ if eq .context.Kind "section" }}
{{ range .context.Sections }}
{{ partial "utils/get-keywords.html" (dict "type" $.type "context" . "scratch" $.scratch) }}
{{ end }}
{{ range .context.Pages }}
{{ partial "utils/get-keywords.html" (dict "type" $.type "context" . "scratch" $.scratch) }}
{{ end }}
{{ else }}
{{ if eq .type "tags" }}
{{ range .context.Params.tags }}
{{ if not (eq . "") }}
{{ $.scratch.Add $.type (slice .) }}
{{ end }}
{{ end }}
{{ else if eq .type "categories" }}
{{ range .context.Params.categories }}
{{ if not (eq . "") }}
{{ $.scratch.Add $.type (slice .) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{/* Only available for first occurrence of method */}}
{{ if .removeDuplicates }}
{{ .scratch.Set .type (uniq (.scratch.Get .type)) }}
{{ end }}
{{ .scratch.Set .type (sort (.scratch.Get .type)) }}
|