mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-30 11:13:06 +00:00
17 lines
No EOL
1.1 KiB
HTML
17 lines
No EOL
1.1 KiB
HTML
{{- $page := .page }}
|
|
{{- if and (not $page) .context }}
|
|
{{- $page = .context }}
|
|
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'badge' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/releasenotes/5/#5-18-0" $page.File.Filename }}
|
|
{{- end }}
|
|
{{- $color := .color | default "" }}
|
|
{{- $content := .content }}
|
|
{{- $style := .style | default "default" }}
|
|
{{- $boxStyle := partial "_relearn/boxStyle.gotmpl" (dict "style" $style "title" .title "icon" .icon) }}
|
|
{{- $title := trim ($boxStyle.title) " " }}
|
|
{{- $icon := trim ($boxStyle.icon) " " }}
|
|
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
|
|
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
|
|
{{- end }}
|
|
{{- with $page -}}
|
|
<span class="badge cstyle {{ $style }}{{ if or $icon $title }} badge-with-title{{ end }}">{{ if or $icon $title }}<span class="badge-title">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ if $title }}{{ $title | .RenderString }}{{ end }}</span>{{ end }}<span class="badge-content"{{ if $color }} style="background-color: {{ $color }};"{{ end }}>{{ $content | safeHTML }}</span></span>
|
|
{{- end }} |