{{- $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 }}
