get-hero.html 714 B

12345678910111213141516171819
  1. {{/* check if there is any hero image in the same folder as the markdown file */}}
  2. {{ $heroImage := .Page.Resources.GetMatch "hero.{jpg,png,svg}"}}
  3. {{ .Scratch.Set "heroScratch" $heroImage }}
  4. {{/* if hero image is not provided, then use the default hero image */}}
  5. {{ if not $heroImage }}
  6. {{ $heroImage := resources.Get "images/default-hero.jpg"}}
  7. {{ .Scratch.Set "heroScratch" $heroImage }}
  8. {{ end }}
  9. {{ $heroImage := .Scratch.Get "heroScratch" }}
  10. {{/* resize hero image. don't resize if the image is an svg */}}
  11. {{ if and $heroImage (ne $heroImage.MediaType.SubType "svg") }}
  12. {{ $heroImage := $heroImage.Resize "148x" }}
  13. {{ end }}
  14. {{/* return the hero image */}}
  15. {{ return $heroImage.RelPermalink }}