mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 20:15:25 +00:00
feat: update widget page to get backgrounds from assets/media/ dir
See #2119
This commit is contained in:
1 parent
6b9fdd9482
commit
33e92dc8cb
1 file changed
+7
-3
@@ -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") }}
|
||||
|
||||
Reference in new issue
Block a user