Transition to Hugo Image Processing (#173)

* Update layout to use Hugo Image Processing.

Created shortcode rimg that uses the srcset attribute to display responsive images.

* Copy Static images to assets folder.

* Add image processing to missing components + Update examples

* Fix rendering in https://themes.gohugo.io/

Co-authored-by: Emruz Hossain <emruz@appscode.com>
This commit is contained in:
Patrick Magauran 2020-12-31 15:55:28 -05:00 committed by GitHub
parent ba1d6014d9
commit a2b3c7fda2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 352 additions and 75 deletions

View file

@ -1,5 +1,19 @@
{{ $heroImage:= "/assets/images/default-hero.jpg"}}
{{ if .Params.hero }}
{{ $heroImage = .Params.hero }}
{{/* 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 "images/default-hero.jpg"}}
{{ .Scratch.Set "heroScratch" $heroImage }}
{{ end }}
{{ return $heroImage }}
{{ $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 }}