2023-09-23 19:25:51 +01:00
|
|
|
{{- $context := . -}}
|
2023-08-26 15:01:06 +01:00
|
|
|
{{- $link := .Get "link" -}}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- $title := .Get "title" -}}
|
|
|
|
{{- $icon := .Get "icon" -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- $subtitle := .Get "subtitle" -}}
|
|
|
|
{{- $image := .Get "image" -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
{{- $width := 0 -}}
|
|
|
|
{{- $height := 0 -}}
|
2023-09-24 15:30:17 +01:00
|
|
|
{{- $imageStyle := .Get "imageStyle" -}}
|
2024-08-11 18:30:19 +02:00
|
|
|
{{- $tag := .Get "tag" -}}
|
2024-08-11 18:47:03 +01:00
|
|
|
{{- $tagType := .Get "tagType" -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
|
|
|
|
{{/* Image processing options */}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- $method := .Get "method" | default "Resize" | humanize -}}
|
|
|
|
{{- $options := .Get "options" | default "800x webp q80" -}}
|
2025-01-06 06:00:00 +11:00
|
|
|
{{- $process := .Get "process" | default (printf "%s %s" $method $options) -}}
|
2023-07-28 22:10:48 +01:00
|
|
|
|
2025-01-18 18:05:13 +01:00
|
|
|
{{- if and $image (not (urls.Parse $image).Scheme) -}}
|
|
|
|
{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
|
|
|
|
{{/* .Process does not work on svgs */}}
|
|
|
|
{{- if (not (eq .MediaType.SubType "svg")) -}}
|
|
|
|
{{/* Retrieve the $image resource from local or global resources */}}
|
|
|
|
{{- $processed := .Process $process -}}
|
|
|
|
{{- $width = $processed.Width -}}
|
|
|
|
{{- $height = $processed.Height -}}
|
|
|
|
{{- $image = $processed.RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{ else }}
|
|
|
|
{{/* Otherwise, use relative link of the image */}}
|
|
|
|
{{- if hasPrefix $image "/" -}}
|
|
|
|
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
|
|
|
|
{{- end -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
2024-03-31 12:06:47 +02:00
|
|
|
{{- partial "shortcodes/card" (dict
|
|
|
|
"page" .Page
|
|
|
|
"link" $link
|
|
|
|
"title" $title
|
|
|
|
"icon" $icon
|
|
|
|
"subtitle" $subtitle
|
|
|
|
"image" $image
|
|
|
|
"width" $width
|
|
|
|
"height" $height
|
|
|
|
"imageStyle" $imageStyle
|
2024-08-11 18:30:19 +02:00
|
|
|
"tag" $tag
|
2024-08-11 18:47:03 +01:00
|
|
|
"tagType" $tagType
|
2024-03-31 12:06:47 +02:00
|
|
|
)
|
|
|
|
-}}
|