Files
hextra/layouts/_shortcodes/icon.html
T

28 lines
644 B
HTML
Raw Normal View History

{{- /*
Create an icon.
@param {string} name The name of the icon.
@param {string} attributes The attributes of the icon.
or
@param {string} 0 The name of the icon.
@example {{< icon name="github" >}}
@example {{< icon "github" >}}
*/ -}}
2023-08-18 23:18:50 +01:00
{{- $name := .Get "name" | default (.Get 0) -}}
{{- $icon := index site.Data.icons $name -}}
{{- $attributes := .Get "attributes" | default "height=1em"}}
2023-08-18 00:16:49 +01:00
{{- if not $icon -}}
{{ errorf "icon %q not found" $name }}
2023-08-18 00:16:49 +01:00
{{- end -}}
{{- $icon = replaceRE "<svg" (printf "<svg %s" $attributes) $icon -}}
<span class="hx:inline-block hx:align-text-bottom hextra-icon">
2023-08-18 00:16:49 +01:00
{{- $icon | safeHTML -}}
</span>