mirror of
https://github.com/thegeeklab/hugo-geekdoc.git
synced 2024-11-04 20:30:40 +00:00
Robert Kaussow
460d27814a
BREAKING CHANGE: 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.
62 lines
2.5 KiB
HTML
62 lines
2.5 KiB
HTML
{{- $name := .Get "name" -}}
|
|
{{- $sort := .Get "sort" -}}
|
|
{{- $order := default "asc" (.Get "order") -}}
|
|
{{- $showAnchor := (and (default true .Page.Params.geekdocAnchor) (default true .Page.Site.Params.geekdocAnchor)) -}}
|
|
|
|
{{- if .Site.Data.properties }}
|
|
<dl class="gdoc-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 gdoc-props__meta"{{ if $showAnchor }} id="{{ $uniqueAnchor }}"{{ end }}>
|
|
<span class="gdoc-props__title">{{ .name }}</span>
|
|
{{- if .required }}
|
|
<span class="gdoc-props__tag warning">{{ i18n "propertylist_required" | lower }}</span>
|
|
{{- else }}
|
|
<span class="gdoc-props__tag tip">{{ i18n "propertylist_optional" | lower }}</span>
|
|
{{- end }}
|
|
{{- with .type }}
|
|
<span class="gdoc-props__tag note">{{ . }}</span>
|
|
{{- end }}
|
|
|
|
{{- with .tags }}
|
|
{{- $tags := . }}
|
|
{{- if reflect.IsMap $tags }}
|
|
{{- $tags = (index $tags $.Site.Language.Lang) }}
|
|
{{- end }}
|
|
{{- range $tags }}
|
|
<span class="gdoc-props__tag">{{ . }}</span>
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if $showAnchor }}
|
|
<a data-clipboard-text="{{ .Page.Permalink }}#{{ $uniqueAnchor }}" class="gdoc-page__anchor clip flex align-center" title="{{ i18n "title_anchor_prefix" }} {{ .name | safeHTML }}" aria-label="{{ i18n "title_anchor_prefix" }} {{ .name | safeHTML }}" href="#{{ $uniqueAnchor }}">
|
|
<svg class="gdoc-icon gdoc_link"><use xlink:href="#gdoc_link"></use></svg>
|
|
</a>
|
|
{{- end }}
|
|
</dt>
|
|
<dd>
|
|
<div class="gdoc-props__description">
|
|
{{- with .description }}
|
|
{{- $desc := . }}
|
|
{{- if reflect.IsMap $desc }}
|
|
{{- $desc = (index $desc $.Site.Language.Lang) }}
|
|
{{- end }}
|
|
{{ $desc | $.Page.RenderString }}
|
|
{{- end }}
|
|
</div>
|
|
<div class="gdoc-props__default">
|
|
{{- with default "none" (.defaultValue | string) }}
|
|
<span>{{ i18n "propertylist_default" | title }}:</span>
|
|
<span>{{ . }}</span>
|
|
{{- end }}
|
|
</div>
|
|
</dd>
|
|
{{- end }}
|
|
{{- end }}
|
|
</dl>
|
|
{{- end }}
|