Theme update

This commit is contained in:
Patrick Neff 2019-02-25 22:46:25 +01:00
parent 5d9ff87a16
commit 23dacd6e29
5 changed files with 116 additions and 63 deletions

View File

@ -1,12 +1,22 @@
{{- $ctx := . -}} {{- $ctx := . -}}
{{- $page := (index .Pages 0) -}} {{- $page := (index .Pages 0) -}}
{{- $image := "" -}} {{- $image := "" -}}
{{- $images := slice -}}
{{- with $page -}} {{- with $page -}}
{{- $image = index ($page.Resources.ByType "image") 0 }} {{- $images = $page.Resources.ByType "image" }}
{{- else -}} {{- else -}}
{{- $image = index (.Resources.ByType "image") 0 -}} {{- $images = .Resources.ByType "image" -}}
{{- end -}} {{- end -}}
{{ with $image }} {{- range $images -}}
{{ if .Params.featured }}
{{ $image = . }}
{{ end }}
{{ end }}
{{ if $image }}
{{ else }}
{{ $image = index $images 0 }}
{{ end }}
{{ with $images }}
<li class="padding"> {{- partial "figure.html" (dict "ctx" $ctx "image" $image "class" "gallery" "showTitle" true "showDescription" true) -}} <li class="padding"> {{- partial "figure.html" (dict "ctx" $ctx "image" $image "class" "gallery" "showTitle" true "showDescription" true) -}}
</li> </li>
{{ end }} {{ end }}

View File

@ -2,11 +2,12 @@
{{- $alt := .ctx.Params.alt -}} {{- $alt := .ctx.Params.alt -}}
{{- $description := .ctx.Params.description | markdownify -}} {{- $description := .ctx.Params.description | markdownify -}}
{{- $keep := .keepOriginal -}} {{- $keep := .keepOriginal -}}
{{- $class := .class -}}
{{- $href := .ctx.Params.href }} {{- $href := .ctx.Params.href }}
<figure {{- with .class }} class="{{ . }}"{{- end -}}> <figure {{- with .class }} class="{{ . }}"{{- end -}}>
<a href="{{- with $href -}}{{ . }}{{ else }}{{ .ctx.Permalink }}{{ end }}"{{- with .lightbox }} data-lightbox{{- end -}}> <a href="{{- with $href -}}{{ . }}{{ else }}{{ .ctx.Permalink }}{{ end }}"{{- with .lightbox }} data-lightbox{{- end -}}>
{{- partial "img.html" (dict "image" .image "ctx" .ctx "keepOriginal" $keep) -}} {{- partial "img.html" (dict "image" .image "ctx" .ctx "keepOriginal" $keep "class" $class) -}}
</a> </a>
<figcaption class="description"> <figcaption class="description">
{{- if .showTitle -}} {{- if .showTitle -}}

View File

@ -7,18 +7,23 @@
{{- with .ctx.Params.alt -}} {{- with .ctx.Params.alt -}}
{{- $alt = . -}} {{- $alt = . -}}
{{- end -}} {{- end -}}
{{- with .class -}}
{{- $class := . -}}
{{- end -}}
{{- $ctx := .ctx -}} {{- $ctx := .ctx -}}
{{ with .image }} {{ with .image }}
{{- $class := "" -}}
{{ if eq $keep true }} {{ if eq $keep true }}
<img alt="{{ $alt }}" <img alt="{{ $alt }}"
title="{{ $title }}" title="{{ $title }}"
class="original" class="original {{- $class }}"
src="{{ .RelPermalink }}" /> src="{{ .RelPermalink }}" />
{{ else }} {{ else }}
{{- $imageSm := .Fill "300x300 Top" -}} {{- $imageSm := .Fill "300x300 Top" -}}
{{- $imageMd := .Fill "500x500 Top" -}} {{- $imageMd := .Fill "500x500 Top" -}}
<img alt="{{ $alt }}" <img alt="{{ $alt }}"
title="{{ $title }}" title="{{ $title }}"
class="{{ $class }}"
srcset="{{ $imageSm.RelPermalink }} 300w, {{ $imageMd.RelPermalink }} 500w" srcset="{{ $imageSm.RelPermalink }} 300w, {{ $imageMd.RelPermalink }} 500w"
sizes="(max-width: 300px) 300px, 500px" sizes="(max-width: 300px) 300px, 500px"
src="{{ $imageMd.RelPermalink }}" /> src="{{ $imageMd.RelPermalink }}" />

View File

@ -1,63 +1,46 @@
{{- $search := "**.jpg" -}} {{- $search := "**.jpg" -}}
{{ with .Get "search" -}}
{{- $search = . }}
{{- else -}}
{{- $search = .Get 0 -}}
{{- end -}}
{{- $keep := false -}} {{- $keep := false -}}
{{- $title := true -}}
{{- $description := true -}}
{{- $lightbox := true -}}
{{- if .IsNamedParams -}}
{{- with .Get "search" -}}
{{ $search = . }}
{{- end -}}
{{- with .Get "original" -}} {{- with .Get "original" -}}
{{- $keep = . }} {{- $keep = . }}
{{- else -}}
{{- $keep = .Get 3 -}}
{{- end -}} {{- end -}}
{{- if eq $keep "true" -}}
{{- $keep = true -}}
{{- else -}}
{{- $keep = false -}}
{{- end -}}
{{- $title := true -}}
{{- with .Get "title" -}} {{- with .Get "title" -}}
{{- $title = . }} {{ $title = . }}
{{- else -}}
{{- $title = .Get 1 -}}
{{- end -}} {{- end -}}
{{- if eq $title "false" -}}
{{- $title = false -}}
{{- else -}}
{{- $title = true -}}
{{- end -}}
{{- $description := true -}} {{- $description := true -}}
{{- with .Get "description" -}} {{ with .Get "description" -}}
{{- $description = . }}
{{- else -}}
{{- $description = .Get 2 -}}
{{- end -}} {{- end -}}
{{- if eq $description "false" -}}
{{- $description = false -}}
{{- else -}}
{{- $description = true -}}
{{- end -}}
{{- $lightbox := true -}}
{{- with .Get "lightbox" -}} {{- with .Get "lightbox" -}}
{{- $lightbox = . }} {{ $lightbox = . }}
{{- else -}}
{{- $lightbox = .Get 2 -}}
{{- end -}} {{- end -}}
{{- if eq $lightbox "false" -}}
{{- $lightbox = false -}}
{{- else -}} {{- else -}}
{{- $lightbox = true -}} {{- with .Get 0 -}}
{{ $search = . }}
{{- end -}}
{{- with .Get 1 -}}
{{ $title = . }}
{{- end -}}
{{- with .Get 2 -}}
{{ $description = . }}
{{- end -}}
{{- with .Get 3 -}}
{{ $keep = . }}
{{- end -}}
{{- with .Get 4 -}}
{{ $lightbox = . }}
{{- end -}}
{{- end -}} {{- end -}}
<ul class="clearfix list-unstyled flex row gallery"> <ul class="clearfix list-unstyled flex row gallery">
{{ if .Inner }}
{{ .Inner }}
{{ else }}
{{ range $.Page.Resources.Match $search }} {{ range $.Page.Resources.Match $search }}
{{- if (ne .Params.featured true) -}} {{- if (ne .Params.featured true) -}}
<li class="padding"> <li class="padding">
@ -65,4 +48,5 @@
</li> </li>
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}}
</ul> </ul>

View File

@ -1,2 +1,55 @@
{{ $image := $.Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }} {{ $search := "**.jpg" }}
{{ partial "figure.html" (dict "image" $image "ctx" $image "class" (.Get 1) "lightbox" true "showTitle" true "showDescription" true) }} {{ $class := "" }}
{{ $title := "" }}
{{ $alt := "" }}
{{ $description := "" }}
{{ $lightbox := true }}
{{ $showTitle := true }}
{{ $showDescription := true }}
{{ $list := false }}
{{ if .IsNamedParams }}
{{ with .Get "search" }}
{{ $search = .}}
{{ end }}
{{ with .Get "class" }}
{{ $class = .}}
{{ end }}
{{ with .Get "title" }}
{{ $title = .}}
{{ end }}
{{ with .Get "description" }}
{{ $description = .}}
{{ end }}
{{ with .Get "alt" }}
{{ $alt = .}}
{{ else }}
{{ $alt = $description}}
{{ end }}
{{ with .Get "lightbox" }}
{{ $lightbox = .}}
{{ end }}
{{ with .Get "showTitle" }}
{{ $showTitle = .}}
{{ end }}
{{ with .Get "showDescription" }}
{{ $showTitle = .}}
{{ end }}
{{ with .Get "list" }}
{{ $list = .}}
{{ end }}
{{ else }}
{{ with .Get 0 }}
{{ $search = . }}
{{ end }}
{{ with .Get 1 }}
{{ $class = . }}
{{ end }}
{{ end }}
{{ $image := $.Page.Resources.GetMatch $search }}
{{ if $list }}
<li class="padding">
{{ end }}
{{ partial "figure.html" (dict "image" $image "ctx" $image "class" $class "lightbox" $lightbox "showTitle" $showTitle "showDescription" $showDescription) }}
{{ if $list }}
</li>
{{ end }}