Add icons helper
This commit is contained in:
parent
ebe608f8c9
commit
2d7954c1d1
3 changed files with 16 additions and 1 deletions
9
layouts/partials/helpers/icons.html
Normal file
9
layouts/partials/helpers/icons.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{{ $svg := . }}
|
||||
{{ $class := print $svg "-icon" }}
|
||||
{{ $match := "<svg (.*)?>(.*)</svg>" }}
|
||||
|
||||
{{ $replaceWith := printf `<svg class="%s icon" ${1}>${2}</svg>` $class }}
|
||||
{{ return (replaceRE $match $replaceWith (printf "/assets/icons/%s.svg" $svg | readFile) | safeHTML) }}
|
||||
|
||||
{{/* Taken from https://bitbanged.com/posts/how-to-use-inline-svgs-with-hugo/ */}}
|
||||
{{/* Only works if SVG is on one line! */}}
|
Loading…
Add table
Add a link
Reference in a new issue