mirror of
https://github.com/foo-dogsquared/hugo-theme-more-contentful.git
synced 2025-01-30 22:57:57 +00:00
Gabriel Arazas
2aeb76fe93
The icon templates are pretty limited to what I want to do. This is also nice for those who are extending the theme with easy-to-use functions.
10 lines
393 B
XML
10 lines
393 B
XML
{{- /*
|
|
This template applies an ID to an SVG from the Simple Icons set to be used with `<use>` element.
|
|
*/ -}}
|
|
{{- $match := "<svg (.*)?>\\s*(.*)\\s*</svg>" }}
|
|
{{- $name := default .id .name }}
|
|
{{- $icon := resources.Get (printf "svg/simple-icons/%s.svg" .id) }}
|
|
{{- $replaceWith := printf `<svg id="%s" ${1}>${2}</svg>` $name }}
|
|
|
|
{{- replaceRE $match $replaceWith $icon.Content | safeHTML }}
|