Skip to content

Commit

Permalink
feat: update widget page to get backgrounds from assets/media/ dir
Browse files Browse the repository at this point in the history
See #2119
  • Loading branch information
gcushen committed Feb 26, 2021
1 parent 6b9fdd9 commit 33e92dc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions wowchemy/layouts/partials/widget_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@
{{ end }}

{{ if $bg.image }}
{{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}}
{{ $media_dir := $.Scratch.Get "media_dir" }}
{{ $style_bg = printf "%sbackground-image: url('%s');" $style_bg (printf "%s/%s" $media_dir $bg.image | absURL) }}
{{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}}#
{{ $bg_img := resources.Get (printf "media/%s" $bg.image) }}
{{ if $bg_img }}
{{ $style_bg = printf "%sbackground-image: url('%s');" $style_bg .Permalink }}
{{ else }}
{{ errorf "Couldn't find `%s` in the `assets/media/` folder - please add it." $bg.image }}
{{ end }}
{{ with $bg.image_size }}
{{/* Allow sizes: actual, cover, and contain. */}}
{{ $style_bg = printf "%sbackground-size: %s;" $style_bg (replace . "actual" "auto") }}
Expand Down

0 comments on commit 33e92dc

Please sign in to comment.