2024-04-21 18:46:21 +08:00
|
|
|
---
|
|
|
|
title: 图标
|
2025-08-14 19:07:25 +08:00
|
|
|
next: /docs/guide/shortcodes/steps
|
2024-04-21 18:46:21 +08:00
|
|
|
---
|
|
|
|
|
2025-08-14 19:07:25 +08:00
|
|
|
要在行内使用此短代码,需在配置中启用行内短代码功能:
|
2024-04-21 18:46:21 +08:00
|
|
|
|
|
|
|
```yaml {filename="hugo.yaml"}
|
|
|
|
enableInlineShortcodes: true
|
|
|
|
```
|
|
|
|
|
2025-08-14 19:07:25 +08:00
|
|
|
可用图标列表可在 [`data/icons.yaml`](https://github.com/imfing/hextra/blob/main/data/icons.yaml) 中找到。
|
2024-04-21 18:46:21 +08:00
|
|
|
|
|
|
|
<!--more-->
|
|
|
|
|
|
|
|
## 示例
|
|
|
|
|
|
|
|
{{< icon "academic-cap" >}}
|
|
|
|
{{< icon "cake" >}}
|
|
|
|
{{< icon "gift" >}}
|
|
|
|
{{< icon "sparkles" >}}
|
|
|
|
|
2025-08-14 19:07:25 +08:00
|
|
|
## 使用方法
|
2024-04-21 18:46:21 +08:00
|
|
|
|
|
|
|
```
|
|
|
|
{{</* icon "github" */>}}
|
|
|
|
```
|
|
|
|
|
2025-08-14 19:07:25 +08:00
|
|
|
默认支持 [Heroicons](https://v1.heroicons.com/) v1 轮廓风格图标。
|
2024-04-21 18:46:21 +08:00
|
|
|
|
2024-12-31 00:34:20 +00:00
|
|
|
### 如何添加自定义图标
|
2024-04-21 18:46:21 +08:00
|
|
|
|
2025-08-14 19:07:25 +08:00
|
|
|
创建 `data/icons.yaml` 文件,按以下格式添加您的 SVG 图标:
|
2024-04-21 18:46:21 +08:00
|
|
|
|
|
|
|
```yaml {filename="data/icons.yaml"}
|
2025-08-14 19:07:25 +08:00
|
|
|
your-icon: <svg>您的图标 SVG 内容</svg>
|
2024-04-21 18:46:21 +08:00
|
|
|
```
|
|
|
|
|
2025-08-14 19:07:25 +08:00
|
|
|
随后即可通过短代码调用:
|
2024-04-21 18:46:21 +08:00
|
|
|
|
|
|
|
```
|
|
|
|
{{</* icon "your-icon" */>}}
|
|
|
|
|
|
|
|
{{</* card icon="your-icon" */>}}
|
|
|
|
```
|
|
|
|
|
2025-08-14 19:07:25 +08:00
|
|
|
提示:[Iconify Design](https://iconify.design/) 是寻找网站 SVG 图标的优质资源平台。
|