diff options
author | Alex Shpak <alex-shpak@users.noreply.github.com> | 2019-05-22 14:37:31 +0200 |
---|---|---|
committer | Alex Shpak <alex-shpak@users.noreply.github.com> | 2019-05-22 14:37:55 +0200 |
commit | 0e6864f5aad8072fbdcecaad48c0151d231b1d25 (patch) | |
tree | 0c29f67a3222db94b1ca828dd8fe113606f7aa04 /layouts | |
parent | 8f5aaee7aaf82a8939deb715483a1c45fe45efa8 (diff) |
#39, Add expand and tabs shortcodes
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/shortcodes/expand.html | 12 | ||||
-rw-r--r-- | layouts/shortcodes/tab.html | 12 | ||||
-rw-r--r-- | layouts/shortcodes/tabs.html | 19 |
3 files changed, 43 insertions, 0 deletions
diff --git a/layouts/shortcodes/expand.html b/layouts/shortcodes/expand.html new file mode 100644 index 0000000..049fdd1 --- /dev/null +++ b/layouts/shortcodes/expand.html @@ -0,0 +1,12 @@ +<div class="book-expand"> + <label> + <div class="book-expand-head flex justify-between"> + <span>{{ default "Expand" (.Get 0) }}</span> + <span>{{ default "↕" (.Get 1) }}</span> + </div> + <input type="checkbox" style="display: none" /> + <div class="book-expand-content markdown-inner"> + {{- .Inner | markdownify -}} + </div> + </label> +</div> diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html new file mode 100644 index 0000000..24520e7 --- /dev/null +++ b/layouts/shortcodes/tab.html @@ -0,0 +1,12 @@ +{{ if .Parent }} + {{ $name := .Get 0 }} + {{ $group := printf "tabs-%s" (.Parent.Get 0) }} + + {{ if not (.Parent.Scratch.Get $group) }} + {{ .Parent.Scratch.Set $group slice }} + {{ end }} + + {{ .Parent.Scratch.Add $group (dict "Name" $name "Content" .Inner) }} +{{ else }} + {{- errorf "%q: tab shortcode must be inside tabs shortcode" .Page.Path -}} +{{ end}} diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html new file mode 100644 index 0000000..65c1f02 --- /dev/null +++ b/layouts/shortcodes/tabs.html @@ -0,0 +1,19 @@ +{{ if .Inner }}{{ end }} +{{ $id := .Get 0 }} +{{ $group := printf "tabs-%s" $id }} + +<div class="book-tabs"> + <div class="book-tabs-head"> + {{ range $index, $tab := .Scratch.Get $group}} + <label for="{{ printf "%s-%d" $group $index }}"> + <span>{{ $tab.Name }}</span> + </label> + {{ end }} + </div> + {{ range $index, $tab := .Scratch.Get $group}} + <input type="radio" name="{{ $group }}" style="display: none;" id="{{ printf "%s-%d" $group $index }}" {{ if not $index }}checked="checked"{{ end }} /> + <div class="book-tabs-content markdown-inner"> + <span>{{ .Content | markdownify }}</span> + </div> + {{ end }} +</div> |