From bf9c6af1b78924c431e48bd8eefd5b1a5b1bc130 Mon Sep 17 00:00:00 2001 From: Paul Payne Date: Sun, 24 Aug 2025 11:16:25 -0700 Subject: [PATCH] Allows coloring of standard icon shortcode. --- layouts/shortcodes/icon.html | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 layouts/shortcodes/icon.html diff --git a/layouts/shortcodes/icon.html b/layouts/shortcodes/icon.html new file mode 100644 index 0000000..0fe434f --- /dev/null +++ b/layouts/shortcodes/icon.html @@ -0,0 +1,11 @@ +{{- /* Avoid extra whitespace */ -}} +{{- /* https://discourse.gohugo.io/t/55399/5 */ -}} +{{- $icon := resources.Get (printf "icons/%s.svg" ($.Get 0)) -}} +{{- $color := $.Get 1 | default "currentColor" -}} +{{- if $icon -}} + + {{- strings.Replace $icon.Content "\n" "" | safeHTML -}} + +{{- else -}} + {{- errorf `icon shortcode: resource "%s" not found. Check the path is correct or remove the shortcode: %s` (printf "icons/%s.svg" ($.Get 0)) .Position -}} +{{- end -}}