Add image processing to missing components + Update examples

This commit is contained in:
Emruz Hossain 2021-01-01 01:41:40 +06:00
parent 94138f89f0
commit 7317ba53de
26 changed files with 171 additions and 111 deletions

View file

@ -1,15 +1,19 @@
{{ $heroImage := .Page.Resources.GetMatch "hero.{jpg,png}"}}
{{/* check if there is any hero image in the same folder as the markdown file */}}
{{ $heroImage := .Page.Resources.GetMatch "hero.{jpg,png,svg}"}}
{{ .Scratch.Set "heroScratch" $heroImage }}
{{/* if hero image is not provided, then use the default hero image */}}
{{ if not $heroImage }}
{{ $heroImage:= resources.Get "default-hero.jpg"}}
{{ .Scratch.Set "heroScratch" $heroImage }}
{{ $heroImage:= resources.Get "images/default-hero.jpg"}}
{{ .Scratch.Set "heroScratch" $heroImage }}
{{ end }}
{{ $heroImage := .Scratch.Get "heroScratch" }}
{{ if $heroImage }}
{{ $heroImage := $heroImage.Resize "148x" }}
{{ return $heroImage.RelPermalink }}
{{/* 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 }}