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"
draft: true
image: ""
sex: male
headless: true
---

View File

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

View File

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

View File

@ -1,16 +1,23 @@
{{ with .Site.GetPage "person" }}
{{/*{{ $person := . }}*/}}
{{ with .GetPage ($.Get "name") }}
{{ $imageName := .Params.Get "image" }}
{{ $image := "" }}
{{ with .Resources.GetMatch $imageName}}
{{ $image = . }}
{{ $image = .RelPermalink }}
{{ else }}
{{ warnf "Image for %s is not correclty found. Falling back to default." ($.Get "name") }}
{{ with .Resources.ByType "image" }}
{{ $image = index . 0 }}
{{ $image = (index . 0).RelPermalink }}
{{ 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 }}
{{ $config :=