diff --git a/assets/img/background.svg b/assets/img/background.svg new file mode 100644 index 00000000..da0496d2 --- /dev/null +++ b/assets/img/background.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/img/featured.svg b/assets/img/featured.svg new file mode 100644 index 00000000..bc7c4f7f --- /dev/null +++ b/assets/img/featured.svg @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/assets/img/gradient.svg b/assets/img/gradient.svg new file mode 100644 index 00000000..2c66fd62 --- /dev/null +++ b/assets/img/gradient.svg @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index ed3328af..40c0d8be 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -18,7 +18,7 @@ mainSections = ["docs"] disableImageOptimization = false disableTextInHeader = false -defaultBackgroundImage = "/img/ocean.jpg" +defaultBackgroundImage = "/img/gradient.svg" defaultFeaturedImage = "/img/ocean.jpg" highlightCurrentMenuArea = true diff --git a/layouts/partials/article-link/card-related.html b/layouts/partials/article-link/card-related.html index b1fcb2ba..c7dbcc35 100644 --- a/layouts/partials/article-link/card-related.html +++ b/layouts/partials/article-link/card-related.html @@ -19,7 +19,7 @@ {{ end }} {{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} {{- with $featured -}} - {{ if $disableImageOptimization }} + {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} {{ with . }} {{ end }} diff --git a/layouts/partials/article-link/card.html b/layouts/partials/article-link/card.html index 53c9c768..dd2a7884 100644 --- a/layouts/partials/article-link/card.html +++ b/layouts/partials/article-link/card.html @@ -20,7 +20,7 @@ {{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} {{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }} {{- with $featured -}} - {{ if $disableImageOptimization }} + {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} {{ with . }}
{{ end }} diff --git a/layouts/partials/article-link/simple.html b/layouts/partials/article-link/simple.html index 24bf281b..afee4875 100644 --- a/layouts/partials/article-link/simple.html +++ b/layouts/partials/article-link/simple.html @@ -47,7 +47,7 @@ {{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} {{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }} {{- with $featured -}} - {{ if $disableImageOptimization }} + {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} {{ with . }}
{{ end }} diff --git a/layouts/partials/hero/background.html b/layouts/partials/hero/background.html index f43cd843..1f6e3fb3 100644 --- a/layouts/partials/hero/background.html +++ b/layouts/partials/hero/background.html @@ -30,10 +30,12 @@ (and ($.Site.Params.list.layoutBackgroundHeaderSpace | default true) ($isParentList)) ) }} {{- with $featured -}} + {{ if $shouldAddHeaderSpace | default true}}
{{ end }} -{{ if $disableImageOptimization }} + +{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} {{ with . }}
diff --git a/layouts/partials/hero/basic.html b/layouts/partials/hero/basic.html index 00cc1b3c..4d01bb23 100644 --- a/layouts/partials/hero/basic.html +++ b/layouts/partials/hero/basic.html @@ -1,14 +1,27 @@ {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{- $images := .Resources.ByType "image" -}} -{{- $featured := $images.GetMatch "*feature*" -}} +{{- $featured := $images.GetMatch "*background*" -}} +{{- if not $featured }}{{ $featured = $images.GetMatch "*feature*" }}{{ end -}} {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{ if .Params.featureimage }} + +{{ if and .Params.featureimage (not $featured) }} {{- $url:= .Params.featureimage -}} -{{- if not $featured }}{{ $featured = resources.GetRemote $url }}{{ end -}} +{{ $featured = resources.GetRemote $url }} {{ end }} + +{{- if not $featured }} + {{ with .Site.Params.defaultBackgroundImage }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ $featured = resources.GetRemote . }} + {{ else }} + {{ $featured = resources.Get . }} + {{ end }} + {{ end }} +{{ end -}} + {{- with $featured -}} - {{ if $disableImageOptimization }} + {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} {{ with . }}
{{ end }} diff --git a/layouts/partials/hero/big.html b/layouts/partials/hero/big.html index 294c37e5..4b61b833 100644 --- a/layouts/partials/hero/big.html +++ b/layouts/partials/hero/big.html @@ -1,18 +1,44 @@ {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{- $images := .Resources.ByType "image" -}} -{{- $featured := $images.GetMatch "*feature*" -}} +{{- $featured := $images.GetMatch "*background*" -}} +{{- if not $featured }}{{ $featured = $images.GetMatch "*feature*" }}{{ end -}} {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{ $caption := "" }} + {{ if .Params.featureimage }} {{- $url:= .Params.featureimage -}} -{{- $caption = .Params.featureimagecaption -}} {{- if not $featured }}{{ $featured = resources.GetRemote $url }}{{ end -}} {{ end }} + +{{- if not $featured }} + {{ with .Site.Params.defaultBackgroundImage }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ $featured = resources.GetRemote . }} + {{ else }} + {{ $featured = resources.Get . }} + {{ end }} + {{ end }} +{{ end -}} + +{{ $caption := "" }} +{{ if .Params.featureimagecaption }} +{{- $caption = .Params.featureimagecaption -}} +{{ end }} + {{- $alt := .Page.Title -}} {{- with .Page.Params.alt }}{{ $alt = . }}{{ end -}} + {{- with $featured -}} - {{ if $disableImageOptimization }} + {{ if strings.HasSuffix $featured ".svg" }} + {{ with . }} +
+ {{ $alt }} + {{ if $caption }} +
{{ $caption | markdownify }}
+ {{end}} +
+ {{ end }} + {{ else if $disableImageOptimization }} {{ with . }}
{{ $alt }} diff --git a/layouts/partials/hero/thumbAndBackground.html b/layouts/partials/hero/thumbAndBackground.html index 5d9c6071..4b807ac1 100644 --- a/layouts/partials/hero/thumbAndBackground.html +++ b/layouts/partials/hero/thumbAndBackground.html @@ -20,7 +20,7 @@ ) }} {{- with $featured -}} -{{ if $disableImageOptimization }} +{{ if or $disableImageOptimization (strings.HasSuffix . ".svg")}} {{ with . }}
{{ end }} @@ -33,7 +33,7 @@ {{- with $background -}} -{{ if $disableImageOptimization }} +{{ if or $disableImageOptimization (strings.HasSuffix . ".svg")}} {{ with . }}