Allows coloring of standard icon shortcode.

This commit is contained in:
2025-08-24 11:16:25 -07:00
parent 6ede2e83cf
commit bf9c6af1b7

View File

@@ -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 -}}
<span class="relative inline-block align-text-bottom icon" style="color: {{ $color }};">
{{- strings.Replace $icon.Content "\n" "" | safeHTML -}}
</span>
{{- 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 -}}