2023-02-18 00:38:04 +00:00
{{- if ( and ( .Get "src" ) ( .Get "chart-id" ) ) -}}
{{- errorf "Both chart ID and resource source defined" -}}
{{- end -}}
2023-01-29 18:50:16 +00:00
{{ $src := $.Page.Resources.GetMatch (.Get "src") }}
2023-07-01 03:16:59 +00:00
{{ if ( and ( not $src ) ( not ( .Get "chart-id" ) ) ) }}
2023-08-07 22:23:46 +00:00
{{- errorf "No Page Resource found for src '%q' (%q)" ( .Get "src" ) .Page.File.Path -}}
2023-04-08 18:57:21 +00:00
{{ end }}
2023-02-18 00:38:04 +00:00
{{ $linkedResource := $.Page.Resources.GetMatch (.Get "link") }}
2022-11-11 05:48:02 +00:00
2023-07-01 03:16:59 +00:00
< figure class = "article__figure figure{{ with .Get " class " } } { { . } } { { end } } " >
2023-02-18 00:38:04 +00:00
{{- with .Get "chart-id" -}}
< canvas class = "figure__chart" id = "{{ . }}" >
You must enable Javascript to view this chart.
< / canvas >
{{- else -}}
{{- if .Get "link" -}}
{{- if $linkedResource }}
< a href = "{{ $linkedResource.RelPermalink }}" { { with . Get " rel " } } rel = "{{ . }}" { { end } } >
{{ else }}
2023-07-01 03:16:59 +00:00
< a href = "{{ .Get " link " } } " >
2023-02-18 00:38:04 +00:00
{{ end }}
2023-01-29 18:50:16 +00:00
{{- end -}}
2023-02-18 00:38:04 +00:00
{{- if eq $src.ResourceType "image" -}}
2023-07-01 03:16:59 +00:00
< picture class = "figure__picture"
itemprop="image">
< img class = "u-photo figure__image"
2023-04-13 23:40:11 +00:00
{{ if ( or ( eq $src.MediaType.SubType "svg" ) ( eq $src.MediaType.SubType "gif" ) ) }}
2023-04-08 18:57:21 +00:00
src="{{ $src.RelPermalink }}"
{{ else }}
2023-07-01 03:16:59 +00:00
{{ with $src.Resize "1200x webp" }}
2023-04-08 18:57:21 +00:00
src="{{ .RelPermalink }}"
{{ end }}
width="{{ $src.Width }}"
height="{{ $src.Height }}"
2023-02-18 00:38:04 +00:00
{{ end }}
2023-07-01 03:16:59 +00:00
{{- with $src.Params.alt }}
alt="{{ . }}"
2023-02-18 00:38:04 +00:00
{{- end -}}
2023-07-01 03:16:59 +00:00
{{- with $src.Params.title }} title="{{ . }}" {{ end -}}
loading="lazy"
role="img"
2023-02-18 00:38:04 +00:00
/>
< / picture >
{{- else if eq $src.ResourceType "video" -}}
{{- if eq $src.MediaType "video/ogg" -}}
2023-07-01 03:16:59 +00:00
< audio class = "u-audio figure__audio" itemprop = "audio" controls >
2023-02-18 00:38:04 +00:00
< source src = "{{ $src.RelPermalink }}" type = "{{ $src.MediaType }}" / >
2023-07-01 03:16:59 +00:00
< p > Your browser doesn't support embedded audio, < a href = "{{ $src.RelPermalink }}" > view the audio here< / a > .< / p >
2023-02-18 00:38:04 +00:00
< / audio >
{{- else -}}
2023-07-01 03:16:59 +00:00
< video class = "u-video figure__video"
2023-02-18 00:38:04 +00:00
controls
src="{{ $src.RelPermalink }}"
2023-07-01 03:16:59 +00:00
poster="
{{- if $src.Params.poster -}}
{{- $posterSrc := $.Page.Resources.GetMatch ( .Get $src.Params.poster ) -}}
{{- with $posterSrc.Resize "1200x webp" -}}
{{- .RelPermalink -}}
{{- end -}}
{{- else -}}
2023-08-07 22:23:46 +00:00
{{- warnf "No poster defined for resource %q (%q)" $src.RelPermalink .Page.File.Path -}}
2023-07-01 03:16:59 +00:00
{{- end -}}
"
itemprop="video"
2023-02-18 00:38:04 +00:00
>
2023-07-01 03:16:59 +00:00
Your browser doesn't support embedded video, < a href = "{{ $src.RelPermalink }}" > view the video here< / a > .
2023-02-18 00:38:04 +00:00
< / video >
{{- end -}}
2023-07-01 03:16:59 +00:00
{{- else if ( or ( ne $src.ResourceType "image" ) ( ne $src.ResourceType "video" ) ) -}}
2023-02-18 00:38:04 +00:00
{{- errorf "No handling for resource of type %q" $src.ResourceType -}}
{{- end -}}
{{- if .Get "link" }}< / a > {{ end -}}
2023-01-29 18:50:16 +00:00
{{- end -}}
2023-02-18 00:38:04 +00:00
{{- if or ( .Get "caption" ) ( .Get "title" ) ( $src.Params.attr ) -}}
< figcaption class = "figure__caption{{ if not ( or ( .Get " caption " ) ( . Get " title " ) ) } } figure__caption--no-height { { end } } " >
{{- with $src -}}
{{ if .Params.attrlink -}}
2023-07-01 03:16:59 +00:00
< a class = "figcaption__attrlink" href = "{{ .Params.attrlink }}" >
2023-02-18 00:38:04 +00:00
{{- end -}}
{{- if .Params.attr -}}< p class = "figcaption__attr" > {{ .Params.attr | safeHTML }}{{ with .Params.attrlicence }} < span class = "figcaption__licence" > {{ . | safeHTML }}< / span > {{ end }}< / p > {{- end -}}
{{- if .Params.attrlink -}}
< / a >
{{- end -}}
2022-11-11 05:48:02 +00:00
{{- end -}}
2023-07-01 03:16:59 +00:00
{{- with .Get "title" -}}< h4 class = "figcaption__title" > {{ . | markdownify | safeHTML }}< / h4 > {{- end -}}
2023-02-18 00:38:04 +00:00
{{- with .Get "caption" -}}
2023-07-01 03:16:59 +00:00
< p class = "figcaption__caption" > {{ . | markdownify | safeHTML }}< / p >
2022-11-11 05:48:02 +00:00
{{- end -}}
< / figcaption >
{{- end -}}
< / figure >