{{ define "main" }}
{{ if isset .Params "image" }}
{{ with resources.GetRemote .Params.image }} {{ with .Err }} {{ errorf "%s" . }} {{ else }} {{ $image := . }} {{ $image := $image.Resize "250x" }} Book cover of the book {{ .Title }} {{ end }} {{ else }} {{ errorf "unable to get remote resource %q" .Params.image }} {{ end }}
{{ end }}

{{ .Title }}

{{ with .Params.last_read }} {{ $last := index (.) 0 }} {{/* if last_read is an array get the first item */}}
Finished on: {{ $last | time.Format ":date_full" }}
{{ end }}
Rating: {{ if isset .Params "rating" }} {{ $rating := .Params.rating }} {{ range (seq $rating) }} ⭐ {{ end }} {{ $diff := sub 5 $rating }} {{ range (seq $diff) }} ☆ {{ end }} {{ else }} N/A {{ end }}
{{ if isset .Params "amazon" }}
Links: Amazon
{{ end }}
{{- .Content -}}
{{ end }}