From b89cd62afb84dd00e7eebfc7d7c13e4b8dcd59b7 Mon Sep 17 00:00:00 2001 From: Regis Philibert Date: Thu, 9 Jun 2022 10:05:20 -0400 Subject: Only apply the absURL on images served through satic directory This will solve the subdirectory edge case without communication Fixes #556 --- layouts/_default/summary-with-image.html | 1 - layouts/partials/func/GetFeaturedImage.html | 4 +++- layouts/partials/page-header.html | 1 - layouts/partials/site-header.html | 1 - layouts/partials/summary-with-image.html | 1 - 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/layouts/_default/summary-with-image.html b/layouts/_default/summary-with-image.html index 3c94240..0467891 100644 --- a/layouts/_default/summary-with-image.html +++ b/layouts/_default/summary-with-image.html @@ -4,7 +4,6 @@
{{ if $featured_image }} {{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}} - {{ $featured_image := (trim $featured_image "/") | absURL }}
image from {{ .Title }} diff --git a/layouts/partials/func/GetFeaturedImage.html b/layouts/partials/func/GetFeaturedImage.html index 12ffe1c..8d250c7 100644 --- a/layouts/partials/func/GetFeaturedImage.html +++ b/layouts/partials/func/GetFeaturedImage.html @@ -20,7 +20,9 @@ {{ $matches := "feature,cover" }} {{/* Use the value from front matter if present */}} {{ with .Params.featured_image }} - {{ $linkToCover = . }} + {{/* This is the default case, the image lives in the static directory. + In which case we'll use the static dir */}} + {{ $linkToCover = trim . "/" | absURL }} {{/* If we find a Page Resource matching the exact value, we use it instead. */}} {{ with $.Resources.GetMatch . }} {{ $linkToCover = .RelPermalink }} diff --git a/layouts/partials/page-header.html b/layouts/partials/page-header.html index 9e46054..8fbaea3 100644 --- a/layouts/partials/page-header.html +++ b/layouts/partials/page-header.html @@ -1,7 +1,6 @@ {{ $featured_image := partial "func/GetFeaturedImage.html" . }} {{ if $featured_image }} {{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}} - {{ $featured_image := (trim $featured_image "/") | absURL }}