Add icons helper
This commit is contained in:
parent
ebe608f8c9
commit
2d7954c1d1
3 changed files with 16 additions and 1 deletions
5
assets/shortcodes/_icons.scss
Normal file
5
assets/shortcodes/_icons.scss
Normal file
|
@ -0,0 +1,5 @@
|
|||
.icon {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
fill: currentColor;
|
||||
}
|
|
@ -1 +1,2 @@
|
|||
@import "verticalposts";
|
||||
@import "verticalposts";
|
||||
@import "icons";
|
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…
Reference in a new issue