mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-23 05:30:41 +00:00
Robert Kaussow
aef6f59ee1
The way anchors are generated for `properties` of a `propertylist` has changed to be unique, even if the shortcode is used multiple times on a page.
54 lines
2.1 KiB
HTML
54 lines
2.1 KiB
HTML
{{- $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 }}>
|
|
<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 }}">
|
|
<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 }}
|