2025-08-15 03:09:58 +02:00
|
|
|
{{- /*
|
|
|
|
|
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) -}}
|
2023-09-26 08:15:31 +01:00
|
|
|
{{- $icon := index site.Data.icons $name -}}
|
|
|
|
|
{{- $attributes := .Get "attributes" | default "height=1em"}}
|
2023-08-18 00:16:49 +01:00
|
|
|
|
|
|
|
|
{{- if not $icon -}}
|
2023-09-26 08:15:31 +01:00
|
|
|
{{ errorf "icon %q not found" $name }}
|
2023-08-18 00:16:49 +01:00
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
|
|
{{- $icon = replaceRE "<svg" (printf "<svg %s" $attributes) $icon -}}
|
|
|
|
|
|
2025-08-13 22:55:38 +08:00
|
|
|
<span class="hx:inline-block hx:align-text-bottom hextra-icon">
|
2023-08-18 00:16:49 +01:00
|
|
|
{{- $icon | safeHTML -}}
|
|
|
|
|
</span>
|