feat: add support for icon in badge shortcode (#525)

* feat: add icon support to badge shortcodes

- Introduced an optional icon parameter to both badge.html files.
- Updated the badge rendering to include the icon alongside the content.
- Enhanced the layout for better alignment of icon and text.

* feat: add new feature shortcode

* docs: update badge doc
This commit is contained in:
Xin
2024-12-28 13:50:22 +00:00
committed by GitHub
parent 26a298da5d
commit 79bb4504a0
4 changed files with 22 additions and 5 deletions

View File

@ -34,16 +34,15 @@ Result:
{{< badge content="warning" type="warning" >}} &nbsp;
{{< badge content="error" type="error" >}}
With link:
With link and icon:
```
{{</* badge content="Releases" link="https://github.com/imfing/hextra/releases" */>}}
{{</* badge content="Releases" link="https://github.com/imfing/hextra/releases" icon="github" */>}}
```
Result:
{{< badge content="Releases" link="https://github.com/imfing/hextra/releases" >}}
{{< badge content="Releases" link="https://github.com/imfing/hextra/releases" icon="github" >}}
## YouTube

View File

@ -0,0 +1,11 @@
{{- $version := .Get "version" | default "" -}}
{{- $icon := .Get "icon" | default "" -}}
{{- $defaultLink := cond (eq $version "") "https://github.com/imfing/hextra/tree/main" (printf "https://github.com/imfing/hextra/releases/tag/%s" $version) -}}
{{- $link := .Get "link" | default $defaultLink -}}
{{- $content := cond (eq $version "") "New in main branch" (printf "New in %s" $version) -}}
<div style="margin-top: 1rem; display: inline-flex;">
<a href="{{ $link }}" title="{{ $link | plainify }}" target="_blank">
{{- partial "shortcodes/badge" (dict "content" $content "border" true "icon" $icon) -}}
</a>
</div>