From 19520b44816895382476fb9eb347dc9ecf190bbd Mon Sep 17 00:00:00 2001 From: Aakash Nand <14219201+aakashnand@users.noreply.github.com> Date: Sat, 10 Feb 2024 23:04:54 +0900 Subject: [PATCH] Ensure featureimage is present before calling resources.GetRemote Also added ability to set author image as external url and updated relevant documentation in configuration --- .../content/docs/configuration/index.md | 2 +- layouts/partials/article-link/simple.html | 2 ++ layouts/partials/author-extra.html | 23 +++++++++++------- layouts/partials/author.html | 23 +++++++++++------- layouts/partials/hero/background.html | 2 ++ layouts/partials/hero/basic.html | 4 ++++ layouts/partials/hero/big.html | 13 +++++++--- layouts/partials/hero/thumbAndBackground.html | 2 ++ layouts/partials/home/background.html | 24 ++++++++++++------- layouts/partials/home/hero.html | 23 +++++++++++------- layouts/partials/home/profile.html | 14 ++++++++++- 11 files changed, 95 insertions(+), 37 deletions(-) diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index 26116149..55ffc084 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -137,7 +137,7 @@ The default file can be used as a template to create additional languages, or re | Name | Default | Description | | ----------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `author.name` | _Not set_ | The author's name. This will be displayed in article footers, and on the homepage when the profile layout is used. | -| `author.image` | _Not set_ | Path to the image file of the author. The image should be a 1:1 aspect ratio and placed in the site's `assets/` folder. | +| `author.image` | _Not set_ | Path to the image file of the author. The image should be a 1:1 aspect ratio. The image can be placed in the site's `assets/` folder or can be external url. | | `author.headline` | _Not set_ | A Markdown string containing the author's headline. It will be displayed on the profile homepage under the author's name. | | `author.bio` | _Not set_ | A Markdown string containing the author's bio. It will be displayed in article footers. | | `author.links` | _Not set_ | The links to display alongside the author's details. The config file contains example links which can simply be uncommented to enable. The order that the links are displayed is determined by the order they appear in the array. Custom links can be added by providing corresponding SVG icon assets in `assets/icons/`. | diff --git a/layouts/partials/article-link/simple.html b/layouts/partials/article-link/simple.html index b0c423b0..bb1768ea 100644 --- a/layouts/partials/article-link/simple.html +++ b/layouts/partials/article-link/simple.html @@ -40,8 +40,10 @@ {{- $images := $.Resources.ByType "image" -}} {{- $featured := $images.GetMatch "*feature*" -}} {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} + {{ if .Params.featureimage }} {{- $url:= .Params.featureimage -}} {{- if not $featured }}{{ $featured = resources.GetRemote $url }}{{ end -}} + {{ end }} {{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} {{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }} {{- with $featured -}} diff --git a/layouts/partials/author-extra.html b/layouts/partials/author-extra.html index 4e81d07e..a15a63c1 100644 --- a/layouts/partials/author-extra.html +++ b/layouts/partials/author-extra.html @@ -1,14 +1,21 @@ {{ $disableImageOptimization := .Site.Params.disableImageOptimization | default false }}