Files
hinode/layouts/shortcodes/release.html
2024-01-01 12:32:39 +01:00

74 lines
2.3 KiB
HTML

<!--
Copyright © 2024 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $error := false }}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "release" "args" .Params) }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{- $version := .Get "version" | default "" -}}
{{- $state := .Get "state" | default "new" -}}
{{- $short := false -}}
{{ with .Get "short" }}{{ $short = partial "utilities/CastBool.html" . }}{{ end -}}
{{- $inline := false -}}
{{ with .Get "inline" }}{{ $inline = partial "utilities/CastBool.html" . }}{{ end -}}
{{- $title := $version -}}
{{- $color := "primary" -}}
{{- if eq $state "deprecated" -}}
{{- $color = "secondary" -}}
{{- end -}}
{{- $size := .Get "size" | default "md" -}}
{{- $class := .Get "class" | default "" -}}
{{- $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 -}}
<!-- Main code -->
{{- 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) " ")
"spacing" $inline)
-}}
{{- if not $inline }}</div>{{ end -}}
{{- end -}}