58 lines
1.3 KiB
HTML
58 lines
1.3 KiB
HTML
{{/* Source:https://gitlab.com/Roneo/hugo-shortcode-roneo-collection */}}
|
|
|
|
{{- $icon := "" -}}
|
|
{{- $theme := "" -}}
|
|
{{- $class := "" -}}
|
|
{{- $href := "" -}}
|
|
|
|
|
|
{{/* Count how many times we've called this shortcode and load the css if it's the first time */}}
|
|
{{- if not ($.Page.Scratch.Get "ico_count") -}}
|
|
<style>
|
|
.ico {
|
|
height: 1.15em;
|
|
width: 1.15em;
|
|
position: relative;
|
|
top: 3px;
|
|
}
|
|
.ico-sm .ico {
|
|
height: .8em;
|
|
width: .8em;
|
|
}
|
|
.ico-md .ico {
|
|
height: 1.5em;
|
|
width: 1.5em;
|
|
}
|
|
.ico-xl .ico {
|
|
height: 2em;
|
|
width: 2em;
|
|
}
|
|
.ico-xxl .ico {
|
|
height: 3em;
|
|
width: 3em;
|
|
}
|
|
</style>
|
|
{{- end -}}
|
|
{{- $.Page.Scratch.Add "ico_count" 1 -}}
|
|
|
|
|
|
{{- if .IsNamedParams }}
|
|
{{- $icon = .Get "icon" -}}
|
|
{{- $theme = (.Get "theme" | default "default") -}}
|
|
{{- $class = .Get "class" -}}
|
|
{{- $href = .Get "href" -}}
|
|
{{- else }}
|
|
{{- $icon = .Get 0 -}}
|
|
{{- $theme = (.Get 1 | default "default") -}}
|
|
{{- $class = .Get 2 -}}
|
|
{{- $href = .Get 3 -}}
|
|
{{- end -}}
|
|
|
|
{{- if not $icon -}}
|
|
{ {- errorf "Missing required 'icon'. Shortcode: 'ico'." -}}
|
|
{{- end -}}
|
|
{{- with .Page.Resources.GetMatch $icon }}
|
|
{{ $icon = . }}
|
|
{{ end -}}
|
|
{{ partial "ico" (dict "icon" $icon "theme" $theme "class" $class "href" $href) }}
|