Skip to content

Commit

Permalink
✨ Feat: open version shortcode, support custom repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Nov 6, 2024
1 parent ad45d89 commit 2a0821f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/init/index.html
Original file line number Diff line number Diff line change
@@ -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" . -}}
Expand Down
7 changes: 4 additions & 3 deletions layouts/shortcodes/version.html
Original file line number Diff line number Diff line change
@@ -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 -}}
<a href="{{ $url }}" rel="external nofollow noopener" target="_blank">
{{- $alt := printf "%v %v | %v" (.Get 3 | default $rvc.name) $version $label -}}
<a href="{{ $url }}" rel="external" target="_blank">
{{- dict "Src" $resource.RelPermalink "Alt" $alt "Class" "version" | partial "plugin/image.html" -}}
</a>
{{- /* EOF */ -}}

0 comments on commit 2a0821f

Please sign in to comment.