diff --git a/CHANGELOG.md b/CHANGELOG.md index eddaa370..45cf0441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file. - :recycle: Refactor: custom.js rendering and remove `params.customJS` ([#189](https://github.com/hugo-fixit/FixIt/pull/189)) - :recycle: Refactor: scss directory ([#185](https://github.com/hugo-fixit/FixIt/issues/185)) - :recycle: Refactor: plugin script +- :recycle: Refactor: version.template.svg - :bug: Fix: add function `dos2unix` to unify new lines symbol between Windows and Unix/Mac OS - :bug: Fix: author display error in post and markdown file - :bug: Fix: use data attributes or class replace for custom attributes diff --git a/assets/svg/version.template.svg b/assets/svg/version.template.svg index 02ffa3b0..ac23a322 100644 --- a/assets/svg/version.template.svg +++ b/assets/svg/version.template.svg @@ -1,20 +1,27 @@ {{- /* https://img.shields.io/badge/$label-$version-$color?style=flat&labelColor=403c3d */ -}} -{{- $labelLength := strings.RuneCount .label | mul 64 | add 100 -}} -{{- $versionLength := strings.RuneCount .version | mul 60 -}} -{{- $width := add $labelLength $versionLength | add 200 -}} - - - {{- $x1 := add $labelLength 100 -}} - {{- $x2 := add $versionLength 100 -}} - - - - - - {{- .label -}} - - - {{- .version -}} - - +{{- $labelWidth := strings.RuneCount .label | mul (cond .isCJK 11.5 8.5) | add 10 -}} +{{- $versionWidth := strings.RuneCount .version | mul 6 | add 10 -}} +{{- $width := add $labelWidth $versionWidth -}} +{{- $labelLength := sub $labelWidth 10 | mul 10 -}} +{{- $versionLength := sub $versionWidth 10 | mul 10 -}} + + {{ .label }}: {{ .version }} + + + + + + + + + + + + + + + {{ .label }} + + {{ .version }} + diff --git a/layouts/shortcodes/version.html b/layouts/shortcodes/version.html index 213777c7..0a921b29 100644 --- a/layouts/shortcodes/version.html +++ b/layouts/shortcodes/version.html @@ -6,9 +6,9 @@ {{- $pathTemplate := cond .Site.IsMultiLingual (printf "svg/version/%%v-%%v.%v.svg" .Page.Language.Lang) "svg/version/%v-%v.svg" -}} {{- $path := printf $pathTemplate $version $type -}} {{- $resource := resources.Get "svg/version.template.svg" -}} -{{- $resource = $resource | resources.ExecuteAsTemplate $path (dict "version" $version "label" $label "color" $color) | minify -}} +{{- $resource = $resource | resources.ExecuteAsTemplate $path (dict "version" $version "label" $label "color" $color "isCJK" .Page.Params.IsCJKLanguage) | minify -}} {{- $alt := printf "FixIt %v | %v" $version $label -}} - + {{- dict "Src" $resource.RelPermalink "Alt" $alt "Class" "version" | partial "plugin/image.html" -}} {{- /* EOF */ -}}