Signed-off-by: hossainemruz <hossainemruz@gmail.com> Signed-off-by: hossainemruz <hossainemruz@gmail.com>
29 lines
1.1 KiB
HTML
29 lines
1.1 KiB
HTML
{{/* check if there is any hero image in the same folder as the markdown file */}}
|
|
{{ $heroImage := .Page.Resources.GetMatch "hero.{jpg,png,svg}"}}
|
|
|
|
{{/* if hero image is specified in the page front-matter, then use that */}}
|
|
{{ if .Params.hero }}
|
|
{{/* try to read from the page bundle */}}
|
|
{{ $heroImage = .Resources.Get .Params.hero }}
|
|
{{/* if the image does not exist in the page bundle,try looking in the assets folder */}}
|
|
{{ if not $heroImage }}
|
|
{{ $heroImage = resources.Get .Params.hero }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ .Scratch.Set "heroScratch" $heroImage }}
|
|
|
|
{{/* if hero image is not provided, then use the default hero image */}}
|
|
{{ if not $heroImage }}
|
|
{{ $heroImage := resources.Get "images/default-hero.jpg"}}
|
|
{{ .Scratch.Set "heroScratch" $heroImage }}
|
|
{{ end }}
|
|
|
|
{{ $heroImage := .Scratch.Get "heroScratch" }}
|
|
|
|
{{/* resize hero image. don't resize if the image is an svg */}}
|
|
{{ if and $heroImage (ne $heroImage.MediaType.SubType "svg") }}
|
|
{{ $heroImage := $heroImage.Resize "148x" }}
|
|
{{ end }}
|
|
|
|
{{/* return the hero image */}}
|
|
{{ return $heroImage.RelPermalink }}
|