Files
mehl.mx/themes/hugo-sustain/layouts/shortcodes/links.html
Max Mehl 9eaac4f8b5 start work to implement a 'read further' separator for the links
Problems: The JS based selectors lead to strange results as in the top5 list there might me no items in the first 5 left. Perhaps a JS-only solution might make sense in the long run
2025-03-17 14:22:25 +01:00

43 lines
2.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{- $type := .Get "type" -}} <!-- e.g. "media" -->
{{- $data := .Site.Data.links -}}
{{- if $type -}}
{{- $data = where $data "type" $type -}}
{{- end }}
{{- $data = sort $data "date" "desc" }}
{{- $datalen := $data | len }}
{{- $limit := (.Get "limit" | default -1) | int }}
{{- $limit_trigger := false }}
<ul>
{{- range $index, $val := $data }}
{{- /* Evaluate limit */}}
{{- if eq $index $limit }}
{{- $limit_trigger = true }}
<details><summary>Show more</summary>
{{- end }}
{{- $tags := slice -}}
{{- range $val.lang }}{{ $tags = $tags | append . }}{{ end -}}
{{- range $val.tags }}{{ $tags = $tags | append . }}{{ end -}}
{{- $tags := slice -}}
{{- range .lang }}{{ $tags = $tags | append . }}{{ end -}}
{{- range .tags }}{{ $tags = $tags | append . }}{{ end -}}
<li class="link" tags="{{ delimit $tags ' ' }}">
{{ .desc -}}&nbsp;&nbsp;
{{- $len := (len .links) -}} <!-- amount of elements under .links -->
{{- range $index, $element := .links -}} <!-- range over links, but keep index -->
{{- with .href }}<a href="{{.}}" target="_blank">{{ end }}{{.text}}{{ with .href }}</a>{{end}}
{{- if ne (add $index 1) $len -}},&#32;{{- end -}} <!-- only append comma if not last element (index starts with 0) -->
{{- end -}}
{{- if or (.video) (.audio) (.slides) }},{{ end -}}
{{ with .video }}&nbsp;<a href="{{ . }}" target="_blank" aria-label="Video Recording"><i class="fas fa-video" aria-hidden="true" title="Video Recording"></i></a>{{ end }}
{{- with .audio }}&nbsp;<a href="{{ . }}" target="_blank" aria-label="Audio Recording"><i class="fas fa-microphone" aria-hidden="true" title="Audio Recording"></i></a>{{ end }}
{{ with .slides }}&nbsp;<a href="{{ . }}" target="_blank" aria-label="Slides"><i class="fas fa-desktop" aria-hidden="true" title="Slides"></i></a>{{ end -}}
{{- with .date }} ({{.}}){{ end -}}
{{ range $tags }}&nbsp;<span class="label label-success">{{ . }}</span>{{ end -}}
</li>
{{ end }}
{{- if $limit_trigger }}
</details>
{{- end }}
</ul>