refactor: resource attribution

This commit is contained in:
Ben Goldsworthy 2025-05-14 17:29:46 +02:00
parent 1a61aeade0
commit 24bfa733ba
No known key found for this signature in database
12 changed files with 169 additions and 99 deletions

View file

@ -54,13 +54,14 @@
{{- if .Get "link" }}</a>{{ end -}}
{{- if or ( .Get "caption" ) ( .Get "title" ) ( $src.Params.attr ) -}}
{{- if or ( .Get "caption" ) ( .Get "title" ) -}}
<figcaption class="figure__caption{{ if not ( or ( .Get "caption" ) ( .Get "title" ) ) }} figure__caption--no-height{{ end }}">
{{- if .Params.attrlink -}}<a class="figcaption__attrlink" href="{{ .Params.attrlink }}">{{- 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 -}}
{{- with .Get "title" -}}<h4 class="figcaption__title">{{ . | markdownify | safeHTML }}</h4>{{- end -}}
{{- with .Get "caption" -}}<p class="figcaption__caption">{{ . | markdownify | safeHTML }}</p>{{- end -}}
</figcaption>
{{- end -}}
{{- if $src.Params -}}
{{- partial "media/attr.html" ( dict "pc" . "sc" $ "params" $src.Params ) -}}
{{- end -}}
</figure>

View file

@ -48,18 +48,8 @@
{{- errorf "No handling for resource of type %q" .ResourceType -}}
{{- end -}}
</a>
{{- if or ( .Params.title ) ( .Params.attr ) -}}
{{- if or ( .Params.title ) -}}
<figcaption class="figure__caption{{ if not .Params.title }} figure__caption--no-height{{ end }}">
{{ if .Params.attrlink -}}
<a class="figcaption__attrlink" href="{{ .Params.attrlink }}"
{{- with .Params.attrtarget }} target="{{ . }}"{{ end -}}
{{- with .Params.attrrel }} rel="{{ . }}"{{ end -}}
>
{{- 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 -}}
{{- if .Params.href -}}
<a href="{{- if ( eq .Params.href "asCite" ) -}}{{ .Params.cite }}{{- else -}}{{ .Params.href }}{{- end -}}">
{{- end -}}
@ -82,6 +72,10 @@
</a>
{{- end -}}
</figcaption>
{{- end -}}
{{- if .Params -}}
{{- partial "media/attr.html" ( dict "pc" . "sc" $ "params" .Params ) -}}
{{- end -}}
</figure>
{{- end }}

View file

@ -29,7 +29,7 @@
{{- end -}}
<!-- Rendering -->
<div>
<div class="picture__wrapper">
{{- if .Get "link" -}}
{{- if $linkedResource -}}
<a href="{{- $linkedResource.RelPermalink -}}"{{- with .Get "rel" }} rel="{{- . -}}"{{- end -}}>
@ -37,13 +37,15 @@
<a href="{{- .Get "link" -}}">
{{- end -}}
{{- end -}}
{{- partial "media/picture.html" $src -}}
{{- if .Get "link" -}}
</a>
{{- end -}}
{{- if $src.Params -}}
{{- partial "media/attr.html" ( dict "pc" . "sc" $ "params" $src.Params ) -}}
{{- end -}}
{{- with ( .Get "caption" ) -}}
<div class="figure__caption"><p class="figcaption__caption">{{ . | safeHTML }}</p></div>
{{- end -}}