mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
26 lines
851 B
HTML
26 lines
851 B
HTML
{{- with .Class -}}
|
|
<i class="{{ . }}" aria-hidden="true"></i>
|
|
{{- else -}}
|
|
{{- $src := .Src -}}
|
|
{{- with .Simpleicons -}}
|
|
{{- $prefix := $.Prefix | default "lib/simple-icons/icons" | strings.TrimSuffix "/" -}}
|
|
{{- $src = printf "%v/%v.svg" $prefix . -}}
|
|
{{- end -}}
|
|
|
|
{{- if not $src -}}
|
|
{{- errorf "Icon src is missing: %s" templates.Current.Filename -}}
|
|
{{- end -}}
|
|
|
|
{{- if (urls.Parse $src).Host | not -}}
|
|
{{- $resource := resources.Get $src | minify -}}
|
|
{{ if not $resource }}
|
|
{{- errorf "Icon does not exist %v" $src -}}
|
|
{{- end -}}
|
|
{{- $resource := $resource.Content -}}
|
|
{{- $resource | replaceRE `<svg ` `<svg class="icon" ` | safeHTML -}}
|
|
{{- else -}}
|
|
{{- /* fetch svg icon from external source */ -}}
|
|
<i data-svg-src="{{ $src }}" aria-hidden="true"></i>
|
|
{{- end -}}
|
|
{{- end -}}
|