docs/layouts/shortcodes/summary-bar.html

82 lines
2.4 KiB
HTML

{{ $featureName := .Get "feature_name" }}
{{ $feature := index site.Data.summary $featureName }}
{{ if not $feature }}
{{ errorf "[summary-bar] invalid feature: %s %v" $featureName .Position }}
{{ end }}
{{ if $feature }}
{{ $subscriptionIcons := dict
"Business" "domain"
"Team" "groups"
"Pro" "person_add"
"Personal" "person"
"Available to all" "public"
}}
{{ $availabilityIcons := dict
"Experimental" "science"
"Beta" "bolt"
"Early Access" "rocket_launch"
"GA" "check_circle"
"Retired" "package_2"
}}
{{ $requiresIcon := "browser_updated" }}
{{ $forIcon := "admin_panel_settings" }}
<div
class="not-prose my-1 flex flex-col border-l-4 border-gray-light-200 bg-gray-light-200 bg-opacity-75 px-4 py-1 dark:bg-gray-dark-300 dark:bg-opacity-75"
>
{{ with $feature.subscription }}
<div class="flex flex-wrap gap-1">
<span class="font-bold">Subscription:</span>
{{ range . }}
<span>{{ . }}</span>
<span class="icon-svg">
{{ $icon := index $subscriptionIcons . }}
{{ if $icon }}
{{ partial "icon" $icon }}
{{ else }}
{{ partial "icon" "default_icon" }}
{{ end }}
</span>
{{ end }}
</div>
{{ end }}
{{ with $feature.availability }}
{{ $availabilityText := . }}
<div class="flex flex-wrap gap-1">
<span class="font-bold">Availability:</span>
<span>
{{ $availabilityText }}
{{ range $key, $icon := $availabilityIcons }}
{{ if in $availabilityText $key }}
<span class="icon-svg">{{ partial "icon" $icon }}</span>
{{ end }}
{{ end }}
</span>
</div>
{{ end }}
{{ with $feature.requires }}
<div class="flex flex-wrap gap-1">
<span class="font-bold">Requires:</span>
<span>{{ . | markdownify }}</span>
<span class="icon-svg">
{{ partial "icon" $requiresIcon }}
</span>
</div>
{{ end }}
{{ with $feature.for }}
<div class="flex flex-wrap gap-1">
<span class="font-bold">For:</span>
<span>{{ . }}</span>
{{ if eq . "Administrators" }}
<span class="icon-svg">
{{ partial "icon" $forIcon }}
</span>
{{ end }}
</div>
{{ end }}
</div>
{{ end }}