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

scratch_set_retalbumthumb.html « partials « layouts - github.com/kc0bfv/autophugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c71858109079e03ee0b83eea51541bf96fe83d1c (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
{{- /*
    Sets retalbumthumb in .Scratch to the correct albumthumb.
    PLEASE NOTE: partials can only get local "dot" . context, they
    do not get the global $ context.  Therefore, you must get the returned
    scratch data from the . context, not from $.

    Requires . to be set to the right section.
    */}}

{{- .Scratch.Delete "retalbumthumb" }}

{{- /* If no albumthumb is set, get the first image*/}}
{{- if or (not (isset .Params "albumthumb")) (eq .Params.albumthumb "") }}
    {{- $imgglob := printf "%s" (path.Join .File.Dir "**") }}
    {{- $imageresources := where (resources.Match $imgglob) "ResourceType" "image" }}
    {{- .Scratch.Set "retalbumthumb" (index $imageresources 0) }}
{{- end }}

{{- /* Otherwise get the albumthumb*/}}
{{- with .Params.albumthumb }}
    {{- $image := resources.Get . }}
    {{- /* The $ here with Scratch means the context outside the with */}}
    {{- $.Scratch.Set "retalbumthumb" $image }}
{{- end }}