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 -}}