Support absolute paths for image resources (#362)

This commit is contained in:
Nedjo Rogers 2022-04-13 12:11:11 -07:00
parent 90d52ed82e
commit 3e01b66d29
2 changed files with 6 additions and 3 deletions

View File

@ -27,12 +27,14 @@
{{ end }}
{{ else }}
{{/* If we find a local global Resource matching the exact value, we use it. */}}
{{ with resources.GetMatch . }}
{{/* Matching uses relative paths so strip a leading / character if present. */}}
{{ with resources.GetMatch (trim . "/") }}
{{ $coverImage = . }}
{{ end }}
{{ end }}
{{/* If we find a Page Resource matching the exact value, we use it instead. */}}
{{ with $.Resources.GetMatch . }}
{{/* Matching uses relative paths so strip a leading / character if present. */}}
{{ with $.Resources.GetMatch (trim . "/") }}
{{ $coverImage = . }}
{{ end }}
{{/* Find the first image with 'cover' in the name in this page bundle. */}}

View File

@ -1,5 +1,6 @@
{{ $srcset := slice }}
{{- with .Page.Resources.GetMatch (.Get "src") -}}
{{/* Matching uses relative paths so strip a leading / character if present. */}}
{{- with .Page.Resources.GetMatch (trim (.Get "src") "/") -}}
{{- /* Standard width of main is 70% (w-70-ns) */ -}}
{{- $target_width := 0.70 -}}
{{ $srcset = partial "func/GetImageSrcset" (dict "original" . "target_width" $target_width) }}