hugo-geekblog/layouts/shortcodes/propertylist.html

54 lines
2.1 KiB
HTML
Raw Normal View History

2023-10-27 19:57:55 +00:00
{{- $name := .Get "name" -}}
{{- $sort := .Get "sort" -}}
{{- $order := default "asc" (.Get "order") -}}
{{- $showAnchor := (and (default true .Page.Params.geekblogAnchor) (default true .Page.Site.Params.geekblogAnchor)) -}}
{{- if .Site.Data.properties }}
<dl class="gblog-props">
{{- with (index .Site.Data.properties (split $name ".")) }}
{{- $properties := .properties }}
{{- with $sort }}
{{- $properties = (sort $properties . $order) }}
{{- end }}
{{- range $properties }}
{{- $uniqueAnchor := anchorize (printf "%s-%s" $name .name) | safeHTML }}
<dt class="flex flex-wrap align-center gblog-props__meta"{{ if $showAnchor }} id="{{ $uniqueAnchor }}"{{ end }}>
2023-10-27 19:57:55 +00:00
<span class="gblog-props__title">{{ .name }}</span>
{{- if .required }}
<span class="gblog-props__tag warning">required</span>
{{- else }}
<span class="gblog-props__tag tip">optional</span>
{{- end }}
{{- with .type }}
<span class="gblog-props__tag note">{{ . }}</span>
{{- end }}
{{- with .tags }}
{{- range . }}
<span class="gblog-props__tag">{{ . }}</span>
{{- end }}
{{- end }}
{{- if $showAnchor }}
<a data-clipboard-text="{{ .Page.Permalink }}#{{ $uniqueAnchor }}" class="gblog-post__anchor clip flex align-center" title="Anchor to: {{ .name | safeHTML }}" aria-label="Anchor to: {{ .name | safeHTML }}" href="#{{ $uniqueAnchor | safeHTML }}">
2023-10-27 19:57:55 +00:00
<svg class="gblog-icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
</a>
{{- end }}
</dt>
<dd>
<div class="gblog-props__description">
{{- with .description }}
{{ . | $.Page.RenderString }}
{{- end }}
</div>
<div class="gblog-props__default">
{{- with default "none" (.defaultValue | string) }}
<span>Default:</span>
<span>{{ . }}</span>
{{- end }}
</div>
</dd>
{{- end }}
{{- end }}
</dl>
{{- end }}