From 2a0821f5317e2fa99cd97d6cdce75262f4f542d9 Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Thu, 7 Nov 2024 00:09:19 +0800
Subject: [PATCH] :sparkles: Feat: open version shortcode, support custom
repository
---
hugo.toml | 7 +++++++
layouts/partials/init/index.html | 2 +-
layouts/shortcodes/version.html | 7 ++++---
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/hugo.toml b/hugo.toml
index 474d4595..72763995 100644
--- a/hugo.toml
+++ b/hugo.toml
@@ -695,6 +695,13 @@ enableEmoji = true
[params.taskList]
# tip = "fa-regular fa-lightbulb"
+ # FixIt 0.3.15 | NEW version shortcode config
+ [params.repoVersion]
+ # url prefix for the release tag
+ url = "https://github.com/hugo-fixit/FixIt/releases/tag/v"
+ # project name
+ name = "FixIt"
+
# FixIt 0.2.12 | NEW PanguJS config
[params.pangu]
# For Chinese writing
diff --git a/layouts/partials/init/index.html b/layouts/partials/init/index.html
index 6ea27012..5d1268ca 100644
--- a/layouts/partials/init/index.html
+++ b/layouts/partials/init/index.html
@@ -1,4 +1,4 @@
-{{- .Scratch.Set "version" "v0.3.15-261f7b66" -}}
+{{- .Scratch.Set "version" "v0.3.15-3ead0107" -}}
{{- .Scratch.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}
diff --git a/layouts/shortcodes/version.html b/layouts/shortcodes/version.html
index db3920af..eb1b5bb5 100644
--- a/layouts/shortcodes/version.html
+++ b/layouts/shortcodes/version.html
@@ -1,14 +1,15 @@
+{{- $rvc := .Page.Param "repoVersion" -}}
{{- $version := .Get 0 -}}
-{{- $url := printf "https://github.com/hugo-fixit/FixIt/releases/tag/v%v" $version -}}
{{- $type := .Get 1 | default "new" | lower -}}
+{{- $url := printf "%v%v" (.Get 2 | default $rvc.url) $version -}}
{{- $label := T (printf "version.%v" $type) -}}
{{- $color := cond (eq $type "changed") "ff9101" "00b1ff" | cond (eq $type "deleted") "ff5252" -}}
{{- $pathTemplate := cond hugo.IsMultilingual (printf "images/version/%%v-%%v.%v.svg" .Page.Language.Lang) "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" .Page.Params.IsCJKLanguage) | minify -}}
-{{- $alt := printf "FixIt %v | %v" $version $label -}}
-
+{{- $alt := printf "%v %v | %v" (.Get 3 | default $rvc.name) $version $label -}}
+
{{- dict "Src" $resource.RelPermalink "Alt" $alt "Class" "version" | partial "plugin/image.html" -}}
{{- /* EOF */ -}}