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

img-path.html « partials « layouts - github.com/jpescador/hugo-future-imperfect.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e6b796e40071525cf5ac3c2dba7a0041a1bb7bdc (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
<!-- This partial is used by the img shortcodes and the template,
     featured in the post type

     Set the path depending on the value passed through

     if path is title then it will use the LinkTitle from the Page variable
     if path is date then it will format the directory to year/date i.e. 2006/01
     Note: path will be concatenated to the root directory, img

     otherwise use the explicit path provided by the user
-->

{{ $src := $.Scratch.Get "path" }}
{{ $alt := $.Scratch.Get "featuredalt" }}
{{ $img := $.Scratch.Get "featured" }}
{{ $structType := $.Scratch.Get "structType" }}

{{ if eq $src "date" }}
  {{ $.Scratch.Set "path" "/img/" }}
  {{ if eq $structType "shortcode" }}
    {{ $.Scratch.Add "path" (.Page.Date.Format "2006/01") }}
  {{ else }}
    {{ $.Scratch.Add "path" (.Date.Format "2006/01") }}
  {{ end }}
{{ else }}
  {{ $.Scratch.Set "path" $src }}
{{ end }}