mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 15:31:52 +00:00
Merge pull request #2268 from servedsmart/move-inline-style-background-image-out-of-line
♻️ Refactor: Move inline styles containing background-image: out of line
This commit is contained in:
@@ -50,6 +50,41 @@
|
||||
{{ if $cssCustom }}
|
||||
{{ $assets.Add "css" (slice $cssCustom) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $images := slice }}
|
||||
{{ $backgroundAndFeaturedImages := slice }}
|
||||
{{ range .Site.Pages }}
|
||||
{{ $images = $images | append (.Page.Resources.ByType "image") }}
|
||||
{{ if .Params.featureimage }}
|
||||
{{ $backgroundAndFeaturedImages = $backgroundAndFeaturedImages | append (resources.GetRemote .Params.featureimage) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $backgroundAndFeaturedImages = $backgroundAndFeaturedImages | append ($images.Match "{*background*,*feature*,*cover*,*thumbnail*}") }}
|
||||
{{ $siteParams := slice .Site.Params.defaultFeaturedImage .Site.Params.defaultBackgroundImage }}
|
||||
{{ range $siteParams }}
|
||||
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
|
||||
{{ $backgroundAndFeaturedImages = $backgroundAndFeaturedImages | append (resources.GetRemote .) }}
|
||||
{{ else }}
|
||||
{{ $backgroundAndFeaturedImages = $backgroundAndFeaturedImages | append (resources.Get .) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
|
||||
{{ range $backgroundAndFeaturedImages }}
|
||||
{{ $classImages := slice }}
|
||||
{{ if or $disableImageOptimization (strings.HasSuffix .Name ".svg") }}
|
||||
{{ $classImages = $classImages | append . }}
|
||||
{{ else }}
|
||||
{{ $classImages = $classImages | append (.Resize "600x") }}
|
||||
{{ $classImages = $classImages | append (.Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x")) }}
|
||||
{{ end }}
|
||||
{{ range $classImages }}
|
||||
{{ $className := printf "background-image-%s" (md5 .RelPermalink) }}
|
||||
{{ $cssBackgroundImage := printf ".%s { background-image: url(\"%s\"); }" $className .RelPermalink }}
|
||||
{{ $cssBackgroundImage = $cssBackgroundImage | resources.FromString "css/background-image.css" }}
|
||||
{{ $assets.Add "css" (slice $cssBackgroundImage) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint
|
||||
(.Site.Params.fingerprintAlgorithm | default "sha512")
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user