Replace title on first page by some thumbnails defined in config

This commit is contained in:
nemunaire 2017-07-25 01:13:43 +02:00 committed by Pierre-Olivier Mercier
commit db7bf2c885
2 changed files with 57 additions and 6 deletions

View file

@ -1,26 +1,27 @@
{{- partial "load-photoswipe-theme.html" . }}
{{ if .IsHome }}
{{ if .Site.Params.homeTitle }}{{ $.Scratch.Set "title" .Site.Params.homeTitle }}{{ else }}{{ $.Scratch.Set "title" .Site.Title }}{{ end }}
{{ if .Site.Params.subtitle }}{{ $.Scratch.Set "subtitle" .Site.Params.subtitle }}{{ end }}
{{ if .Site.Params.bigimg }}{{ $.Scratch.Set "bigimg" .Site.Params.bigimg }}{{ end }}
{{ if .Site.Params.thumb }}{{ $.Scratch.Set "thumb" .Site.Params.thumb }}{{ end }}
{{ else }}
{{ $.Scratch.Set "title" .Title }}
{{ if .Params.subtitle }}{{ $.Scratch.Set "subtitle" .Params.subtitle }}{{ end }}
{{ if .Params.bigimg }}{{ $.Scratch.Set "bigimg" .Params.bigimg }}{{ end }}
{{ if .Params.thumb }}{{ $.Scratch.Set "thumb" .Params.thumb }}{{ end }}
{{ end }}
{{ $bigimg := $.Scratch.Get "bigimg" }}
{{ $title := $.Scratch.Get "title" }}
{{ $subtitle := $.Scratch.Get "subtitle" }}
{{ $thumbs := $.Scratch.Get "thumb" }}
{{ if or $bigimg $title }}
{{ if $bigimg }}
<div id="header-big-imgs" data-num-img={{len $bigimg}}
<div id="header-big-imgs" data-num-img={{len $bigimg}}
{{range $i, $img := $bigimg}}
{{ if (fileExists $img.src)}}
data-img-src-{{add $i 1}}="{{$img.src | absURL }}"
{{ if (fileExists $img.src)}}
data-img-src-{{add $i 1}}="{{$img.src | absURL }}"
{{else}}
data-img-src-{{add $i 1}}="{{$img.src}}"
data-img-src-{{add $i 1}}="{{$img.src}}"
{{end}}
{{ if $img.desc}}data-img-desc-{{add $i 1}}="{{$img.desc}}"{{end}}
{{end}}></div>
@ -85,3 +86,16 @@
{{ else }}
<div class="intro-header"></div>
{{ end }}
{{ if $thumbs }}
<div class="container">
{{range $i, $thumb := $thumbs}}
<a href="{{ $thumb.link | absURL }}" target="_blank">
<div class="thumbApp" style="background-image:url('{{ $thumb.src | absURL }}')">
{{ if $thumb.desc }}<p>{{ $thumb.desc }}</p>{{end}}
</div>
</a>
{{ end }}
<span style="clear:both; display: block"></span>
<hr class="small">
</div>
{{ end }}