18
themes/hugo-sustain/layouts/shortcodes/links.html
Normal file
18
themes/hugo-sustain/layouts/shortcodes/links.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{{- $type := .Get "type" -}} <!-- e.g. "media" -->
|
||||
{{- $data := .Site.Data.links -}}
|
||||
{{- if $type -}}
|
||||
{{- $data = where $data "type" $type -}}
|
||||
{{ end }}
|
||||
{{- range sort $data "date" "desc" }}
|
||||
<ul>
|
||||
<li>{{.desc}} –
|
||||
{{- $len := (len .links) -}} <!-- amount of elements under .links -->
|
||||
{{- range $index, $element := .links -}} <!-- range over links, but keep index -->
|
||||
{{ with .href }}<a href="{{.}}">{{ end }}{{.text}}{{ with .href }}</a>{{end}}
|
||||
{{- if ne (add $index 1) $len -}}, {{- end -}} <!-- only append comma if not last element (index starts with 0) -->
|
||||
{{- end -}}
|
||||
{{- with .date }} ({{.}}){{ end }}
|
||||
{{ range .tags }}<span class="label label-success">{{ . }}</span> {{ end }}
|
||||
</li>
|
||||
</ul>
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user