mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-16 14:33:10 +00:00
104 lines
3.4 KiB
HTML
104 lines
3.4 KiB
HTML
<!--
|
|
Displays a release button that links to a specific release. Use the optional state to indicate if it is a new or
|
|
deprecated feature.
|
|
"version": Required version string, expects semver notation with a "v" prefix.
|
|
"state": Optional state, either "new" or "deprecated".
|
|
"short": Optional flag to indicate the release button should use short notation.
|
|
"size" Optional size of the button, either "sm", "md" (default), or "lg".
|
|
"class": Optional class attribute of the button element.
|
|
"inline": If set, renders the release button inline (defaults to false).
|
|
-->
|
|
|
|
{{- $error := false -}}
|
|
{{- $version := .Get "version" | default "" -}}
|
|
{{- $inline := false -}}
|
|
|
|
{{- $state := .Get "state" | default "new" -}}
|
|
{{- $supportedStates := slice "new" "deprecated" -}}
|
|
{{- if not (in $supportedStates $state) -}}
|
|
{{- errorf "Invalid value for param 'state': %s" .Position -}}
|
|
{{- $error = true -}}
|
|
{{- end -}}
|
|
|
|
{{- $shortParam := "false" -}}
|
|
{{- $short := false -}}
|
|
{{- with .Get "short" }}{{ $shortParam = . }}{{ end -}}
|
|
{{- $supportedFlags := slice "true" "false" -}}
|
|
{{- if in $supportedFlags $shortParam -}}
|
|
{{- if eq $shortParam "true" }}{{ $short = true }}{{ end -}}
|
|
{{- else -}}
|
|
{{- errorf "Invalid value for param 'short': %s" .Position -}}
|
|
{{- $error = true -}}
|
|
{{- end -}}
|
|
|
|
{{- $inlineParam := "false" -}}
|
|
{{- $inline := false -}}
|
|
{{- with .Get "inline" }}{{ $inlineParam = . }}{{ end -}}
|
|
{{- $supportedFlags := slice "true" "false" -}}
|
|
{{- if in $supportedFlags $inlineParam -}}
|
|
{{- if eq $inlineParam "true" }}{{ $inline = true }}{{ end -}}
|
|
{{- else -}}
|
|
{{- errorf "Invalid value for param 'inline': %s" .Position -}}
|
|
{{- $error = true -}}
|
|
{{- end -}}
|
|
|
|
{{- $title := $version -}}
|
|
{{- $color := "primary" -}}
|
|
{{- if eq $state "deprecated" -}}
|
|
{{- $color = "secondary" -}}
|
|
{{- end -}}
|
|
|
|
{{- $icon := "" -}}
|
|
{{- $tooltip := "" -}}
|
|
{{- if eq $state "deprecated" -}}
|
|
{{- if $short -}}
|
|
{{- $icon = "fas trash-can" -}}
|
|
{{- $tooltip = T "deprecatedFeature" $version -}}
|
|
{{ else }}
|
|
{{- $title = T "deprecatedFeature" $version -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- if $short -}}
|
|
{{- $icon = "fas rocket" -}}
|
|
{{- $tooltip = T "addedFeature" $version -}}
|
|
{{ else }}
|
|
{{- $title = T "addedFeature" $version -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
|
|
{{- if not $short -}}
|
|
{{- if eq $state "deprecated" -}}
|
|
{{- $title = T "deprecatedFeature" $version -}}
|
|
{{- else -}}
|
|
{{- $title = T "addedFeature" $version -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- $size := "md" -}}
|
|
{{- with .Get "size" }}{{ $size = . }}{{ end -}}
|
|
{{- $supportedSizes := slice "sm" "md" "lg" -}}
|
|
{{- if not (in $supportedSizes $size) -}}
|
|
{{- errorf "Invalid value for param 'size': %s" .Position -}}
|
|
{{- $error = true -}}
|
|
{{- end -}}
|
|
|
|
{{- $class := .Get "class" | default "" -}}
|
|
|
|
{{- if not $error -}}
|
|
{{- if not $inline }}<div class="pb-3">{{ end -}}
|
|
{{- partial "assets/button.html" (dict
|
|
"title" $title
|
|
"href" (partial "partials/utilities/URLJoin.html" (dict "base" site.Params.docs.release "path" $version))
|
|
"size" "sm"
|
|
"color" $color
|
|
"outline" "true"
|
|
"size" $size
|
|
"icon" $icon
|
|
"tooltip" $tooltip
|
|
"order" "first"
|
|
"class" (trim (printf "rounded-2 fw-semibold %s" $class) " "))
|
|
-}}
|
|
{{- if not $inline }}</div>{{ end -}}
|
|
{{- end -}}
|