forked from drowl87/hextra_mirror
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:
parent
26a298da5d
commit
79bb4504a0
@ -34,16 +34,15 @@ Result:
|
|||||||
{{< badge content="warning" type="warning" >}}
|
{{< badge content="warning" type="warning" >}}
|
||||||
{{< badge content="error" type="error" >}}
|
{{< 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:
|
Result:
|
||||||
|
|
||||||
{{< badge content="Releases" link="https://github.com/imfing/hextra/releases" >}}
|
{{< badge content="Releases" link="https://github.com/imfing/hextra/releases" icon="github" >}}
|
||||||
|
|
||||||
|
|
||||||
## YouTube
|
## YouTube
|
||||||
|
|
||||||
|
11
exampleSite/layouts/shortcodes/new-feature.html
Normal file
11
exampleSite/layouts/shortcodes/new-feature.html
Normal 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>
|
@ -2,6 +2,7 @@
|
|||||||
{{- $type := .type -}}
|
{{- $type := .type -}}
|
||||||
{{- $class := .class | default "" -}}
|
{{- $class := .class | default "" -}}
|
||||||
{{- $border := .border | default false -}}
|
{{- $border := .border | default false -}}
|
||||||
|
{{- $icon := .icon | default "" -}}
|
||||||
|
|
||||||
{{- $defaultClass := "hx-text-gray-600 hx-bg-gray-100 dark:hx-bg-neutral-800 dark:hx-text-neutral-200 hx-border-gray-200 dark:hx-border-neutral-700" -}}
|
{{- $defaultClass := "hx-text-gray-600 hx-bg-gray-100 dark:hx-bg-neutral-800 dark:hx-text-neutral-200 hx-border-gray-200 dark:hx-border-neutral-700" -}}
|
||||||
{{- $warningClass := "hx-border-yellow-100 hx-bg-yellow-50 hx-text-yellow-900 dark:hx-border-yellow-200/30 dark:hx-bg-yellow-700/30 dark:hx-text-yellow-200" -}}
|
{{- $warningClass := "hx-border-yellow-100 hx-bg-yellow-50 hx-text-yellow-900 dark:hx-border-yellow-200/30 dark:hx-bg-yellow-700/30 dark:hx-text-yellow-200" -}}
|
||||||
@ -11,6 +12,9 @@
|
|||||||
{{- $borderClass := cond (eq $border true) "hx-border" "" -}}
|
{{- $borderClass := cond (eq $border true) "hx-border" "" -}}
|
||||||
{{- $badgeClass := cond (eq $type "info") $infoClass (cond (eq $type "warning") $warningClass (cond (eq $type "error") $errorClass $defaultClass)) -}}
|
{{- $badgeClass := cond (eq $type "info") $infoClass (cond (eq $type "warning") $warningClass (cond (eq $type "error") $errorClass $defaultClass)) -}}
|
||||||
<div class="hextra-badge {{ $class }}">
|
<div class="hextra-badge {{ $class }}">
|
||||||
<div class="hx-inline-flex hx-items-center hx-rounded-full hx-px-2.5 hx-leading-6 hx-text-[.65rem] {{ $borderClass }} {{ $badgeClass }}">{{- $content -}}</div>
|
<div class="hx-inline-flex hx-gap-1 hx-items-center hx-rounded-full hx-px-2.5 hx-leading-6 hx-text-[.65rem] {{ $borderClass }} {{ $badgeClass }}">
|
||||||
|
{{- with $icon -}}{{- partial "utils/icon" (dict "name" . "attributes" "height=12") -}}{{- end -}}
|
||||||
|
{{- $content -}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{- /* Strip trailing newline. */ -}}
|
{{- /* Strip trailing newline. */ -}}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
{{- $type := .Get "type" | default "" -}}
|
{{- $type := .Get "type" | default "" -}}
|
||||||
{{- $class := .Get "class" | default "" -}}
|
{{- $class := .Get "class" | default "" -}}
|
||||||
{{- $link := .Get "link" | default "" -}}
|
{{- $link := .Get "link" | default "" -}}
|
||||||
|
{{- $icon := .Get "icon" | default "" -}}
|
||||||
|
|
||||||
{{- if $link -}}
|
{{- if $link -}}
|
||||||
<a href="{{ $link }}" title="{{ $content | plainify }}" target="_blank">
|
<a href="{{ $link }}" title="{{ $content | plainify }}" target="_blank">
|
||||||
@ -11,6 +12,7 @@
|
|||||||
"type" $type
|
"type" $type
|
||||||
"class" $class
|
"class" $class
|
||||||
"border" true
|
"border" true
|
||||||
|
"icon" $icon
|
||||||
)
|
)
|
||||||
-}}
|
-}}
|
||||||
</a>
|
</a>
|
||||||
@ -20,6 +22,7 @@
|
|||||||
"type" $type
|
"type" $type
|
||||||
"class" $class
|
"class" $class
|
||||||
"border" true
|
"border" true
|
||||||
|
"icon" $icon
|
||||||
)
|
)
|
||||||
-}}
|
-}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user