{{ define "main" }}
{{ $contentExists := gt (len .Content) 0 }} {{ $blogPages := where .Site.RegularPages.ByDate.Reverse ".Type" "in" .Site.Params.mainSections }} {{ $blogPages = where $blogPages ".Params.draft" "!=" true }} {{ $showLatest := and (default true site.Params.showBlogLatest) $blogPages }} {{ $headlessExists := false }} {{ if $contentExists }} {{ .Content }} {{ else }} {{ with .Site.GetPage "/homepage" }} {{ $headlessExists = true }}
{{ range .Resources }}

{{ .Title }}

{{ .Content }}

{{ end }}
{{ end }} {{ end }} {{ if and (or $headlessExists $contentExists) $showLatest }}

♦ ♦ ♦

{{ $blogLatest := default "Latest Blog Posts" site.Params.blogLatestHeading }}

{{- $blogLatest -}}

{{ end }} {{ if $showLatest }} {{ with $blogPages }} {{ range first (default 3 site.Params.nBlogLatest) . }} {{- partial "blog-entry-summary" . -}} {{ end }} {{ end }} {{ end }}
{{ end }}