diff options
author | Robert Kaussow <mail@thegeeklab.de> | 2022-07-11 15:37:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 15:37:17 +0300 |
commit | c1f15c2162a30d020f66e200be366905bfbe3b25 (patch) | |
tree | d0f66bf7db6cea2c8053376a0c293337c4eac9e1 /layouts | |
parent | 42f408b2d4842edc26c4a22bbc482ec56f20884e (diff) |
feat: add new boxes shortcode (#274)
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/shortcodes/box.html | 19 | ||||
-rw-r--r-- | layouts/shortcodes/boxes.html | 25 |
2 files changed, 44 insertions, 0 deletions
diff --git a/layouts/shortcodes/box.html b/layouts/shortcodes/box.html new file mode 100644 index 0000000..7b48c4c --- /dev/null +++ b/layouts/shortcodes/box.html @@ -0,0 +1,19 @@ +{{ 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 }} diff --git a/layouts/shortcodes/boxes.html b/layouts/shortcodes/boxes.html new file mode 100644 index 0000000..eead05c --- /dev/null +++ b/layouts/shortcodes/boxes.html @@ -0,0 +1,25 @@ +{{- if .Inner }}{{ end }} +{{- $id := .Get 0 }} +{{- $group := printf "grid-%s" $id }} + + +<div class="flex flex-gap flex-fill"> + {{- range $index, $box := .Scratch.Get $group }} + <div + class="gblog-box gblog-box--{{ $box.Size }} + {{ with $box.Class }}{{ printf " %s" . }}{{ end }}" + > + {{ if or $box.Title $box.Icon }} + <div class="flex align-center justify-center gblog-box__title"> + {{- with $box.Icon }} + <svg class="gblog-icon {{ . }}"><use xlink:href="#{{ . }}"></use></svg> + {{- end }} + {{ with $box.Title }}<span>{{ . }}</span>{{ end }} + </div> + {{ end }} + <div class="flex align-center justify-center gblog-box__text"> + {{ .Content | $.Page.RenderString }} + </div> + </div> + {{- end }} +</div> |