From a611955251fd3984d2f017c25eaaba59ca257ff3 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 6 Jul 2023 22:07:07 +0200 Subject: [PATCH] feat: add option to set custom label on progress shortcode (#412) --- exampleSite/content/posts/advanced/shortcodes.md | 3 ++- layouts/shortcodes/progress.html | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/exampleSite/content/posts/advanced/shortcodes.md b/exampleSite/content/posts/advanced/shortcodes.md index a2de217..838589e 100644 --- a/exampleSite/content/posts/advanced/shortcodes.md +++ b/exampleSite/content/posts/advanced/shortcodes.md @@ -450,7 +450,8 @@ Text continues here. | Name | Description | default | | ---------------- | -------------------------------------------------------------------------------- | --------- | -| value | progress value | 0 | +| value | progress value (0-100) | 0 | +| label | value to display | value | | icon (optional) | icon to use, need to be an icon from an [SVG sprite](/posts/features/icon-sets/) | undefined | | title (optional) | progress title | undefined | diff --git a/layouts/shortcodes/progress.html b/layouts/shortcodes/progress.html index d9da6d4..4b2027e 100644 --- a/layouts/shortcodes/progress.html +++ b/layouts/shortcodes/progress.html @@ -1,4 +1,5 @@ {{- $value := default 0 (.Get "value") -}} +{{- $label := default (printf "%v %%" $value) (.Get "label") -}} {{- $title := .Get "title" -}} {{- $icon := .Get "icon" -}} @@ -11,13 +12,13 @@ {{- end }} {{ with $title }}{{ . }}{{ end }} -
{{ $value }}%
+
{{ $label }}