{{- define "partials/author-list.html" -}}
{{- $authors := . -}}
{{- if and (ne $authors nil) (gt (len $authors) 0) -}}
{{- " by " -}}
{{- range $i, $a := $authors -}}
{{- if and (ne $i 0) (eq (add $i 1) (len $authors)) -}}and {{ end -}}
{{ $a.name }}
{{- if ne (add $i 1) (len $authors) -}}, {{ end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $showCover := ne (.Get 1) false -}}
{{- $book := partial "openlibrary.obj" (dict "path" .Page.Path "id" (.Get 0)) -}}
{{- with $book -}}
{{- if and $showCover .cover -}}
{{- $title := .title -}}
{{- with .cover -}}
{{- end -}}
{{ .title }}
{{- partial "partials/author-list.html" .authors -}}
{{- else -}}
{{ .title }}
{{- partial "partials/author-list.html" .authors -}}
{{- end -}}
{{- end -}}