#98: replacing readFile
with partial
for predefined icons
This approach has been taken from another popular hugo-theme `ananke`:
e3f7fbe39d/layouts/partials/social-follow.html (L41)
Before Width: | Height: | Size: 754 B After Width: | Height: | Size: 754 B |
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 524 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 684 B After Width: | Height: | Size: 684 B |
Before Width: | Height: | Size: 417 B After Width: | Height: | Size: 417 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 556 B After Width: | Height: | Size: 556 B |
Before Width: | Height: | Size: 460 B After Width: | Height: | Size: 460 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 869 B After Width: | Height: | Size: 869 B |
Before Width: | Height: | Size: 730 B After Width: | Height: | Size: 730 B |
@ -1,15 +1,15 @@
|
||||
<span class="inline-svg" >
|
||||
|
||||
|
||||
{{ $dict := newScratch }}
|
||||
|
||||
{{ if (eq .custom true) }}
|
||||
{{ $dict.Set "filename" (print "static/fa-icons/" .iconName ".svg") }}
|
||||
{{ if (eq .custom true) }}
|
||||
{{ $dict.Set "svg" (readFile (print "static/fa-icons/" .iconName ".svg")) }}
|
||||
{{ else }}
|
||||
{{ $dict.Set "filename" (print "themes/anubis/static/fa-icons/" .iconName ".svg") }}
|
||||
{{ $dict.Set "svg" (partial (print "fa-icons/" .iconName ".svg")) }}
|
||||
{{ end }}
|
||||
|
||||
{{- $path:="<path" -}}
|
||||
{{- $fill:="<path fill=\"currentColor\"" -}}
|
||||
{{ replace (readFile ($dict.Get "filename")) $path $fill | safeHTML }}
|
||||
{{ replace ($dict.Get "svg") $path $fill | safeHTML }}
|
||||
|
||||
</span>
|
||||
|