Merge pull request #2372 from ZhenShuo2021/fix/icon-newline

🐛 Fix(icon): trim white space and line break
This commit is contained in:
Nuno C.
2025-08-03 01:40:15 +01:00
committed by GitHub
2 changed files with 12 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
{{ $icon := resources.Get (print "icons/" . ".svg") }}
{{ if $icon }}
{{- $icon := resources.Get (print "icons/" . ".svg") -}}
{{- if $icon -}}
<span class="relative block icon">
{{ $icon.Content | safeHTML }}
{{- $icon.Content | safeHTML -}}
</span>
{{ end }}
{{- end -}}

View File

@@ -1,8 +1,10 @@
{{ $icon := resources.Get (printf "icons/%s.svg" ($.Get 0)) }}
{{ if $icon }}
{{- /* Avoid extra whitespace */ -}}
{{- /* https://discourse.gohugo.io/t/55399/5 */ -}}
{{- $icon := resources.Get (printf "icons/%s.svg" ($.Get 0)) -}}
{{- if $icon -}}
<span class="relative inline-block align-text-bottom icon">
{{ $icon.Content | safeHTML }}
{{- strings.Replace $icon.Content "\n" "" | safeHTML -}}
</span>
{{ else }}
{{ errorf `[BLOWFISH] Shortcode "icon" error in "%s": Resource "%s" not found. Check the path is correct or remove the shortcode.` .Page.Path (printf "icons/%s.svg" ($.Get 0)) }}
{{ end }}
{{- 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 -}}