From c2fc4167c1fb79736f126d3bfb5a8f9a9d326b65 Mon Sep 17 00:00:00 2001 From: vjeantet Date: Sun, 6 Sep 2020 02:05:29 +0200 Subject: added columns and tabs shortcodes --- layouts/shortcodes/columns.html | 9 +++++++++ layouts/shortcodes/notice.html | 6 ++++-- layouts/shortcodes/tab.html | 14 ++++++++++++++ layouts/shortcodes/tabs.html | 18 ++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 layouts/shortcodes/columns.html create mode 100644 layouts/shortcodes/tab.html create mode 100644 layouts/shortcodes/tabs.html (limited to 'layouts') diff --git a/layouts/shortcodes/columns.html b/layouts/shortcodes/columns.html new file mode 100644 index 0000000..3148ff5 --- /dev/null +++ b/layouts/shortcodes/columns.html @@ -0,0 +1,9 @@ + + +
+ {{ range split .Inner "<--->" }} +
+ {{ . | markdownify }} +
+ {{ end }} +
\ No newline at end of file diff --git a/layouts/shortcodes/notice.html b/layouts/shortcodes/notice.html index 12d8378..ea71ace 100644 --- a/layouts/shortcodes/notice.html +++ b/layouts/shortcodes/notice.html @@ -1,8 +1,10 @@ {{ $_hugo_config := `{ "version": 1 }` }}
- {{- if len .Params | eq 2 -}} - + {{with .Params}} + {{- if len $.Params | eq 2 -}} + + {{- end -}} {{- end -}} {{if in .Inner "\n" }}{{.Inner}}{{else}}

{{.Inner}}

{{end}}
diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html new file mode 100644 index 0000000..ab1601d --- /dev/null +++ b/layouts/shortcodes/tab.html @@ -0,0 +1,14 @@ + +{{ if .Parent }} + {{ $name := .Get 0 }} + {{ $group := printf "tabs-%d" .Parent.Ordinal }} + + {{ 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}} \ No newline at end of file diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html new file mode 100644 index 0000000..61958c8 --- /dev/null +++ b/layouts/shortcodes/tabs.html @@ -0,0 +1,18 @@ +{{ $_hugo_config := `{ "version": 1 }` }} + + +{{ if .Inner }}{{ end }} +{{ $group := printf "tabs-%d" .Ordinal }} + +
+{{- range $index, $tab := .Scratch.Get $group -}} + + +
+ {{- .Content | markdownify -}} +
+{{- end -}} +
+ -- cgit v1.2.3