{{ define "global" }}
{{ .Scratch.Set "CSSModules" (slice "list" "page") }}
{{ .Scratch.Set "CSSModulesCritical" (slice) }}
{{ $image := "" }}
{{ $mainPages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $pages := first 5 $mainPages }}
{{ if and (len $pages) (.Params.FeatureFirstArticle) }}
{{ with index $pages 0 }}
{{ $image = partial "helper/image" (dict "Resources" .Resources "Image" .Params.Image) }}
{{ end }}
{{ else }}
{{ $image = partial "helper/image" (dict "Resources" .Resources "Image" .Params.Image) }}
{{ end }}
{{ .Scratch.Set "hasBlurryHero" (and $image (default .Site.Params.Default.Hero.Blurry .Params.Hero.Blurry)) }}
{{ .Scratch.Set "image" $image }}
{{ end }}
{{ define "main" }}
{{ $mainPages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $pages := first 5 $mainPages }}
{{ $ShowImage := false }}
{{ with ($.Scratch.Get "image") }}{{ $ShowImage = true }}{{ end }}
{{ $heroParams := (dict
"Context" .
"Image" ($.Scratch.Get "image")
"Title" (default .Site.Title .Title)
"Description" (default .Site.Params.Description .Params.Description)
"ShowImage" $ShowImage
"ImageWidths" $.Site.Params.Page.Image.Widths
) }}
{{ $SinglePage := .Params.SinglePage }}
{{ $FeatureFirstArticle := and (and (len $pages) (.Params.FeatureFirstArticle)) (not $SinglePage) }}
{{ if $FeatureFirstArticle }}
{{- $latest := index $pages 0 -}}
{{ $heroParams = merge $heroParams (dict
"SmallTitle" "Latest Post"
"Title" (printf `%s` $latest.RelPermalink $latest.Title)
"Description" $latest.Params.Description
) }}
{{ end }}
{{ partial "common/hero" $heroParams }}
{{ if $SinglePage }}
{{ partial "page/main" . }}
{{ else }}
{{ if $FeatureFirstArticle }}
{{- $latest := index $pages 0 -}}
{{- with $latest -}}