{{ $baseURL := "/" | absURL -}} {{ $dot := . -}} {{ $dot.Scratch.Set "path" "" -}} {{ $dot.Scratch.Set "breadcrumb" slice -}} {{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" -}} {{ $.Scratch.Add "path" .Site.BaseURL -}} {{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) -}} {{ range $index, $element := split $url "/" -}} {{ $dot.Scratch.Add "path" $element -}} {{ $.Scratch.Add "path" "/" -}} {{ if ne $element "" -}} {{ $.Scratch.Add "breadcrumb" (slice (dict "url" ($.Scratch.Get "path") "name" . "position" (add $index 2))) -}} {{ end -}} {{ end -}} {{ $images := $.Resources.ByType "image" -}} {{ $feature := $images.GetMatch "*feature*" -}} {{ $feature_param := $.Params.feature_image }} {{ $feature_frontmatter := $images.GetMatch $feature_param }} {{ if $feature_frontmatter -}} {{ $.Scratch.Set "primaryImage" $feature_frontmatter.Permalink }} {{ with $.Params.feature_image_alt }} {{ $.Scratch.Set "primaryImageAlt" . }} {{ end }} {{ else if $feature -}} {{ $.Scratch.Set "primaryImage" $feature.Permalink }} {{ with $.Params.feature_image_alt }} {{ $.Scratch.Set "primaryImageAlt" . }} {{ end }} {{ else if $.Params.images }} {{ $.Scratch.Set "primaryImage" ( index $.Params.images 0 | absURL ) }} {{ else if $.Site.Params.images }} {{ $.Scratch.Set "primaryImage" ( index $.Site.Params.images 0 | absURL ) }} {{ end }}