website/layouts/partials/helpers/icons.html

9 lines
398 B
HTML
Raw Normal View History

2023-01-12 23:07:45 +01:00
{{ $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! */}}