From 5529404d1942ca8b93bea5bb7119e8aaa7ad7041 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Wed, 3 Mar 2021 11:14:50 +0000 Subject: [PATCH] feat: workaround Hugo v0.81 error on Windows with remote figure Hugo v0.81 on Windows will error when figure destination is a remote URL such that we have `resources.Get (path.Join "media" )`. See https://github.com/wowchemy/wowchemy-hugo-modules/discussions/2205 --- wowchemy/layouts/shortcodes/figure.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wowchemy/layouts/shortcodes/figure.html b/wowchemy/layouts/shortcodes/figure.html index d9bcc06c..f15fca8b 100644 --- a/wowchemy/layouts/shortcodes/figure.html +++ b/wowchemy/layouts/shortcodes/figure.html @@ -4,6 +4,7 @@ such as Callout, without the HTML being rendered as a Markdown code block. */}} {{ $destination := .Get "src" }} +{{ $is_remote := strings.HasPrefix $destination "http" }} {{ $caption := .Get "caption" | default (.Get "title") | default "" }}{{/* Support legacy `title` option. */}} {{ $zoom := eq (.Get "lightbox" | default "true") "true" }} {{ $id := anchorize (.Get "id" | default ($caption | plainify)) }} @@ -12,9 +13,13 @@ {{ if eq (.Get "theme" | lower) "light" }}{{ $img_class = printf "%s img-light" $img_class }}{{end}} {{ if eq (.Get "theme" | lower) "dark" }}{{ $img_class = printf "%s img-dark" $img_class }}{{end}} -{{- $img := (.Page.Resources.ByType "image").GetMatch $destination -}} -{{- if not $img -}} - {{- $img = resources.Get (path.Join "media" $destination) -}} +{{/* Workaround Hugo v0.81 error on Windows when `resources.Get (path.Join "media" )` */}} +{{- $img := "" -}} +{{- if not $is_remote -}} + {{- $img = (.Page.Resources.ByType "image").GetMatch $destination -}} + {{- if not $img -}} + {{- $img = resources.Get (path.Join "media" $destination) -}} + {{- end -}} {{- end -}}