hugo-geekblog/layouts/shortcodes/box.html

20 lines
674 B
HTML
Raw Normal View History

2022-07-11 12:37:17 +00:00
{{ if .Parent }}
{{- $group := printf "grid-%s" (.Parent.Get 0) }}
{{- $class := default "" (.Get "class") }}
{{- $size := default "regular" (.Get "size" | lower) }}
{{- $icon := default "" (.Get "icon") }}
{{- $title := default "" (.Get "title") }}
{{- if not (in (slice "regular" "large") $size) }}
{{- $size = "regular" }}
{{- end }}
{{ if not (.Parent.Scratch.Get $group) }}
{{ .Parent.Scratch.Set $group slice }}
{{ end }}
{{ .Parent.Scratch.Add $group (dict "Class" $class "Size" $size "Icon" $icon "Title" $title "Content" .Inner) }}
{{ else }}
{{ errorf "%q: 'box' shortcode must be inside 'boxes' shortcode" .Page.Path }}
{{ end }}