Fix display of persons

This commit is contained in:
Christian Wolf 2023-01-20 15:31:30 +01:00
parent e0946e6c59
commit a025961ad5
4 changed files with 14 additions and 5 deletions

View File

@ -2,5 +2,6 @@
title: "Joseph Ripp" title: "Joseph Ripp"
draft: true draft: true
image: "" image: ""
sex: male
headless: true headless: true
--- ---

View File

@ -2,5 +2,6 @@
title: "{{ replace .Name "-" " " | title }}" title: "{{ replace .Name "-" " " | title }}"
draft: true draft: true
image: "" image: ""
sex: male
headless: true headless: true
--- ---

View File

@ -2,7 +2,7 @@
<div class="image"> <div class="image">
{{- $param := . -}} {{- $param := . -}}
{{- with .image -}} {{- with .image -}}
<img src="{{ .RelPermalink }}" {{ with $param.name }}alt="Bild {{ . }}"{{ end }}> <img src="{{ . }}" {{ with $param.name }}alt="Bild {{ $param.name }}"{{ end }}>
{{- end -}} {{- end -}}
</div> </div>

View File

@ -1,16 +1,23 @@
{{ with .Site.GetPage "person" }} {{ with .Site.GetPage "person" }}
{{/*{{ $person := . }}*/}}
{{ with .GetPage ($.Get "name") }} {{ with .GetPage ($.Get "name") }}
{{ $imageName := .Params.Get "image" }} {{ $imageName := .Params.Get "image" }}
{{ $image := "" }} {{ $image := "" }}
{{ with .Resources.GetMatch $imageName}} {{ with .Resources.GetMatch $imageName}}
{{ $image = . }} {{ $image = .RelPermalink }}
{{ else }} {{ else }}
{{ warnf "Image for %s is not correclty found. Falling back to default." ($.Get "name") }} {{ warnf "Image for %s is not correclty found. Falling back to default." ($.Get "name") }}
{{ with .Resources.ByType "image" }} {{ with .Resources.ByType "image" }}
{{ $image = index . 0 }} {{ $image = (index . 0).RelPermalink }}
{{ else }} {{ else }}
{{/* $image */}} {{ with .Params.Get "sex" }}
{{ if eq . "male" }}
{{ $image = relURL "img/persons/male.png" }}
{{ else }}
{{ errorf "Generic female icon not found." }}
{{ end }}
{{ else }}
{{ warnf "Cannot find sex of %s." ($.Get "name") }}
{{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ $config := {{ $config :=