{{- $post := . -}} {{- $body := $post.RawContent -}} {{- $cover := "" -}} {{- $md := findRESubmatch `!\[[^\]]*\]\(([^)\s]+)` $body 1 -}} {{- if $md -}} {{- $cover = index (index $md 0) 1 -}} {{- else -}} {{- $html := findRESubmatch `]*\ssrc="([^"]+)"` $body 1 -}} {{- if $html -}}{{- $cover = index (index $html 0) 1 -}}{{- end -}} {{- end -}} {{- if and $cover (hasPrefix $cover "./") -}} {{- $cover = printf "%s%s" $post.RelPermalink (replaceRE `^\./` "" $cover) -}} {{- end -}} {{- $cover -}}