mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
♻️ Refactor: icon plugin
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{{- .Scratch.Set "version" "v0.3.10-5e1a7845" -}}
|
||||
{{- .Scratch.Set "version" "v0.3.10-5aaacec0" -}}
|
||||
{{- .Scratch.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
@@ -6,8 +6,20 @@
|
||||
{{- $prefix := $.Prefix | default "lib/simple-icons/icons" | strings.TrimSuffix "/" -}}
|
||||
{{- $src = printf "%v/%v.svg" $prefix . -}}
|
||||
{{- end -}}
|
||||
{{- if (urls.Parse $src).Host | not -}}
|
||||
{{- $src = (resources.Get $src | minify).RelPermalink -}}
|
||||
|
||||
{{ if not $src }}
|
||||
{{- errorf "Icon src is missing" -}}
|
||||
{{- 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 -}}
|
||||
<i data-svg-src="{{ $src }}" aria-hidden="true"></i>
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user