From 0219bb263c3bf9a8135fc2ab22daa4bd72aed58b Mon Sep 17 00:00:00 2001 From: madoke Date: Sun, 13 Nov 2022 23:28:38 +0000 Subject: [PATCH] add default background image to theme --- exampleSite/content/docs/configuration/index.md | 1 + layouts/partials/hero/background.html | 3 ++- layouts/partials/home/background.html | 10 +++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index c0834902..717cd5b5 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -137,6 +137,7 @@ Many of the article defaults here can be overridden on a per article basis by sp | `showLikes` | _Not set_ | Whether or not articles and list likes are displayed. This requires firebase integrations to be enabled, look below. | | `robots` | _Not set_ | String that indicates how robots should handle your site. If set, it will be output in the page head. Refer to [Google's docs](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives) for valid values. | | `disableImageZoom` | `false` | Disables image zoom feature across all the images in the site. | +| `defaultBackgroundImage` | _Not set_ | Default background image for both `background` homepage layout and `background` hero style | | `header.layout` | `"basic"` | Defines the header for the entire site, supported values are `basic` and `fixed`. | | `footer.showMenu` | `true` | Show/hide the footer menu, which can be configured in the `[[footer]]` section of the `config/_default/menus.en.toml` file. | | `footer.showCopyright` | `true` | Whether or not to show the copyright string in the site footer. Note that the string itself can be customised using the `copyright` parameter in the [languages configuration](#language-and-i18n). | diff --git a/layouts/partials/hero/background.html b/layouts/partials/hero/background.html index 1bf1e9ef..01893a07 100644 --- a/layouts/partials/hero/background.html +++ b/layouts/partials/hero/background.html @@ -1,6 +1,7 @@ {{- $images := .Resources.ByType "image" -}} {{- $featured := $images.GetMatch "*feature*" -}} {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} +{{- if not $featured }}{{ with .Site.Params.defaultBackgroundImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} {{- with $featured -}} {{ with .Resize "1200x" }}
@@ -23,4 +24,4 @@ {{ end }} {{ end }} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/layouts/partials/home/background.html b/layouts/partials/home/background.html index b750c72c..f96d3fec 100644 --- a/layouts/partials/home/background.html +++ b/layouts/partials/home/background.html @@ -4,9 +4,10 @@
- {{ with .Site.Params.homepage.homepageImage }} - {{ $homepageImage := resources.Get . }} - {{ if $homepageImage }} + {{ $homepageImage := "" }} + {{ with .Site.Params.defaultBackgroundImage }}{{ $homepageImage = resources.Get . }}{{ end }} + {{ with .Site.Params.homepage.homepageImage }}{{ $homepageImage = resources.Get . }}{{ end }} + {{ if not (eq $homepageImage "") }}
@@ -15,7 +16,6 @@ class="opacity-70 absolute inset-0 h-[1000px] bg-gradient-to-t from-neutral dark:from-neutral-800 to-neutral dark:to-neutral-800 mix-blend-normal">
{{ end }} - {{ end }}
{{ with .Site.Author.image }} @@ -65,4 +65,4 @@ background_blur.style.opacity = (scroll / 300) }); -{{ end }} \ No newline at end of file +{{ end }}