github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/docs/themes/hugo-theme-relearn/layouts/partials/shortcodes/button.html (about) 1 {{- $page := .page }} 2 {{- if and (not $page) .context }} 3 {{- $page = .context }} 4 {{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'button' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }} 5 {{- end }} 6 {{- $color := .color | default "" }} 7 {{- $content := .content }} 8 {{- $href := (trim .href " ") | default "" }} 9 {{- $style := .style | default "default" }} 10 {{- if and (not $color) (eq (len $color) 0) }} 11 {{- $style = .style | default "transparent" }} 12 {{- end }} 13 {{- $target := .target | default "" }} 14 {{- $type := .type | default "" }} 15 {{- $isButton := false }} 16 {{- $isLink := false }} 17 {{- if or $type (strings.HasPrefix $href "javascript:") }} 18 {{- $isButton = true }} 19 {{- $href = substr $href (len "javascript:") }} 20 {{- if not $type }} 21 {{- $type = "button" }} 22 {{- end }} 23 {{- else if not $href }} 24 {{- else if and (eq (len $target) 0) (or (strings.HasPrefix $href "http://") (strings.HasPrefix $href "https://") ) }} 25 {{- $isLink = true }} 26 {{- $target = "_blank" }} 27 {{- if isset $page.Site.Params "externallinktarget" }} 28 {{- $target = $page.Site.Params.externalLinkTarget }} 29 {{- end }} 30 {{- else }} 31 {{- $isLink = true }} 32 {{- end }} 33 {{- $title := .title | default ($content) }} 34 {{- if not $title }} 35 {{- if eq $style "info" }}{{ $title = $style | T }}{{ end }} 36 {{- if eq $style "warning" }}{{ $title = $style | T }}{{ end }} 37 {{- if eq $style "note" }}{{ $title = $style | T }}{{ end }} 38 {{- if eq $style "tip" }}{{ $title = $style | T }}{{ end }} 39 {{- end }} 40 {{- $title = trim $title " " }} 41 {{- $icon := .icon | default "" }} 42 {{- if and (not $icon) (eq (len $icon) 0) }} 43 {{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} 44 {{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} 45 {{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} 46 {{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }} 47 {{- end }} 48 {{- $icon = trim $icon " " }} 49 {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} 50 {{- $icon = printf "fa-fw fas fa-%s" $icon }} 51 {{- end }} 52 {{- $iconposition := .iconposition | default "left" }} 53 {{- with $page -}} 54 <span class="btn cstyle {{ if or $isButton $isLink }}interactive {{ end }}{{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}> 55 {{- if $isButton -}} 56 <button onclick="{{ $href | safeJS }}"{{ if gt (len $type) 0 }} type="{{ $type }}"{{ end }}> 57 {{- else if $isLink -}} 58 <a href="{{ $href }}"{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}> 59 {{- else -}} 60 <span> 61 {{- end }} 62 {{- if and $icon (eq $iconposition "left") }}<i class="{{ $icon }}"></i>{{ end }} 63 {{- if and $icon (eq $iconposition "left") $title }} {{ end }} 64 {{- if $title }}<span class="title">{{- $title | safeHTML }}</span>{{ end }} 65 {{- if and $icon (eq $iconposition "right") $title }} {{ end }} 66 {{- if and $icon (eq $iconposition "right") }}<i class="{{ $icon }}"></i>{{ end }} 67 {{- if $isButton -}} 68 </button> 69 {{- else if $isLink -}} 70 </a> 71 {{- else -}} 72 </span> 73 {{- end -}} 74 </span> 75 {{- end }}