mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 16:15:12 +00:00
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" <URL>)`. See https://github.com/wowchemy/wowchemy-hugo-modules/discussions/2205
This commit is contained in:
1 parent
3952bfc85c
commit
5529404d19
1 file changed
+8
-3
@@ -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" <URL>)` */}}
|
||||
{{- $img := "" -}}
|
||||
{{- if not $is_remote -}}
|
||||
{{- $img = (.Page.Resources.ByType "image").GetMatch $destination -}}
|
||||
{{- if not $img -}}
|
||||
{{- $img = resources.Get (path.Join "media" $destination) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
<figure {{ with .Get "class" }}class="{{.}}"{{ end }} {{ with $id }}id="figure-{{ . }}"{{ end }}>
|
||||
|
||||
Reference in new issue
Block a user