mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-09-03 04:02:40 +00:00
fbdf95b627
feat(rtl): add .fa-feather icon to RTL support
37 lines
1.8 KiB
HTML
37 lines
1.8 KiB
HTML
{{- /*
|
|
Version badge shortcode.
|
|
Renders an inline SVG version badge linking to the repository release/tag.
|
|
|
|
@param {String} 0 - The version string (e.g., "1.0.0")
|
|
@param {String} [1="new"] - The type: "new", "changed", "deleted", "deprecated"
|
|
@param {String} [2] - Custom URL override (defaults to repo_version.url)
|
|
@param {String} [3] - Custom repo name override (defaults to repo_version.name)
|
|
|
|
@example
|
|
{{< version 1.0.0 >}}
|
|
{{< version 0.4.5 deprecated >}}
|
|
*/ -}}
|
|
{{- $rvc := dict "Page" .Page "Key" "repo_version" | partial "function/param.html" | default dict -}}
|
|
{{- $version := .Get 0 -}}
|
|
{{- $type := .Get 1 | default "new" | lower -}}
|
|
{{- $label := T (printf "version.%v" $type) | default (upper $type) -}}
|
|
{{- $isCJK := partial "function/is-cjk.html" . -}}
|
|
{{- $url := printf "%v%v" (.Get 2 | default $rvc.url) $version -}}
|
|
{{- $colorMap := dict
|
|
"new" "#00b1ff"
|
|
"changed" "#81bd65"
|
|
"deleted" "#ff5252"
|
|
"deprecated" "#ff9101"
|
|
-}}
|
|
{{- $color := index $colorMap $type | default (index $colorMap "new") -}}
|
|
{{- $repoName := .Get 3 | default $rvc.name -}}
|
|
{{- $pathTemplate := cond hugo.IsMultilingual (printf "images/version/%%v-%%v.%v.svg" .Page.Language.Name) "images/version/%v-%v.svg" -}}
|
|
{{- $path := printf $pathTemplate $version $type -}}
|
|
{{- $resource := resources.Get "images/version.template.svg" -}}
|
|
{{- $resource = $resource | resources.ExecuteAsTemplate $path (dict "version" $version "label" $label "color" $color "isCJK" $isCJK) | minify -}}
|
|
{{- $alt := printf "%v %v | %v" $repoName $version $label -}}
|
|
<a href="{{ $url }}" rel="external" target="_blank" class="version-link whitespace-nowrap">
|
|
{{- dict "Src" $resource.RelPermalink "Alt" $alt "Class" "version h-[1.25em] align-text-bottom" | partial "plugin/image.html" -}}
|
|
</a>
|
|
{{- /* EOF */ -}}
|