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
parent eb3cf1d783
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 }}

View File

@ -139,6 +139,43 @@ img {
}
}
.thumbApp {
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: cover;
border-radius: 15px 1px 15px 1px;
box-shadow: 0px 0px 10px #555;
font-family: "Linux Biolinum O", 'Helvetica Neue', Helvetica, Arial, sans-serif;
height: 200px;
display: block;
float: left;
margin-right: 0.5%;
margin-bottom: 20px;
width: 24.5%;
}
.thumbApp p {
background-color: rgba(0,0,0,0.7);
border-bottom: solid #333 1px;
color: white;
font-weight: bolder;
margin-top: 130px;
padding: 10px;
line-height: 1.0;
}
.thumbApp p a {
color: white;
}
.thumbApp img {
border-radius: inherit;
width: 100%;
}
.thumbApp .legend {
background: #ddd;
margin-top: -1em;
width: inherit;
}
/* --- Navbar --- */
.navbar-custom {