Welcome to mirror list, hosted at ThFree Co, Russian Federation.

get-keywords.html « utils « partials « layouts - github.com/2-REC/hugo-myportfolio-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d10c6fcb43d354e67c3891fb967b8f41114fd30a (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
{{/*
    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 }}

{{ if (.scratch.Get .type) }}
{{ .scratch.Set .type (sort (.scratch.Get .type)) }}
{{ end }}