From 74f82dae95453c4ebbe97d5bfa15933142a20c9a Mon Sep 17 00:00:00 2001 From: stereobooster Date: Thu, 5 Oct 2023 11:55:18 +0200 Subject: [PATCH] Option to explicitly path resource --- layouts/_default/single.html | 7 +++---- layouts/partials/picture.html | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 80225c0d..d478d7f5 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,8 +1,7 @@ {{ define "main" }} {{- $images := .Resources.ByType "image" }} {{- $cover := $images.GetMatch (.Params.cover | default "*cover*") }} - {{- $feature := (.Params.feature | default "*feature*") | default $cover }} - {{- $featureImg := $images.GetMatch $feature }} + {{- $feature := $images.GetMatch (.Params.feature | default "*feature*") | default $cover }}
{{ if .Params.showBreadcrumbs | default (.Site.Params.article.showBreadcrumbs | default false) }} @@ -14,10 +13,10 @@
{{ partial "article-meta.html" (dict "context" . "scope" "single") }}
- {{ if $featureImg }} + {{ if $feature }}
{{ $alt := $.Params.featureAlt | default $.Params.coverAlt | default "" }} - {{ partial "picture.html" (dict "context" . "src" $feature "alt" $alt "class" "mb-6 -mt-4 rounded-md") }} + {{ partial "picture.html" (dict "context" . "resource" $feature "alt" $alt "class" "mb-6 -mt-4 rounded-md") }} {{ with $.Params.coverCaption }}
{{ . | markdownify }}
{{ end }} diff --git a/layouts/partials/picture.html b/layouts/partials/picture.html index 207f5d07..cdf7a195 100644 --- a/layouts/partials/picture.html +++ b/layouts/partials/picture.html @@ -16,7 +16,9 @@ /> {{ else }} {{ $resource := "" }} - {{ if .context.Page.Resources.GetMatch ($url.String) }} + {{ if .resource }} + {{ $resource = .resource }} + {{ else if .context.Page.Resources.GetMatch ($url.String) }} {{ $resource = .context.Page.Resources.GetMatch ($url.String) }} {{ else if resources.GetMatch ($url.String) }} {{ $resource = resources.Get ($url.String) }}