diff options
author | vjeantet <valere.jeantet@gmail.com> | 2020-09-06 03:05:29 +0300 |
---|---|---|
committer | vjeantet <valere.jeantet@gmail.com> | 2020-09-06 03:05:29 +0300 |
commit | c2fc4167c1fb79736f126d3bfb5a8f9a9d326b65 (patch) | |
tree | f5c23750336c17a5a4d5ed722419a806efec2777 /layouts | |
parent | 182e24047d6d891ef021ff6e3d48fd72f1470b2d (diff) |
added columns and tabs shortcodes
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/shortcodes/columns.html | 9 | ||||
-rw-r--r-- | layouts/shortcodes/notice.html | 6 | ||||
-rw-r--r-- | layouts/shortcodes/tab.html | 14 | ||||
-rw-r--r-- | layouts/shortcodes/tabs.html | 18 |
4 files changed, 45 insertions, 2 deletions
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 @@ +<!-- https://github.com/alex-shpak/hugo-book/blob/master/layouts/shortcodes/columns.html --> +<link rel="stylesheet" type="text/css" href='{{ (resources.Get "sass/shortcodes/columns.scss" | toCSS).Permalink }}'> +<div class="columns"> + {{ range split .Inner "<--->" }} + <div class="column"> + {{ . | markdownify }} + </div> + {{ end }} +</div>
\ 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 }` }} <link rel="stylesheet" type="text/css" href='{{ (resources.Get "sass/shortcodes/notice.scss" | toCSS).Permalink }}'> <div class="notices {{ with .Get 0 -}}{{.}}{{else}}primary{{end}}"> - {{- if len .Params | eq 2 -}} - <label>{{- with .Get 1 -}}{{.}}{{- end -}}</label> + {{with .Params}} + {{- if len $.Params | eq 2 -}} + <label>{{- with $.Get 1 -}}{{.}}{{- end -}}</label> + {{- end -}} {{- end -}} {{if in .Inner "\n" }}{{.Inner}}{{else}}<p>{{.Inner}}</p>{{end}} </div> 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 @@ +<!-- https://github.com/alex-shpak/hugo-book/blame/master/layouts/shortcodes/tab.html --> +{{ 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 }` }} +<!-- https://github.com/alex-shpak/hugo-book/blob/master/layouts/shortcodes/tabs.html --> +<link rel="stylesheet" type="text/css" href='{{ (resources.Get "sass/shortcodes/tabs.scss" | toCSS).Permalink }}'> +{{ if .Inner }}{{ end }} +{{ $group := printf "tabs-%d" .Ordinal }} + +<div class="tabs"> +{{- range $index, $tab := .Scratch.Get $group -}} + <input type="radio" name="{{ $group }}" id="{{ printf "%s-%d" $group $index }}" {{ if not $index }}checked="checked"{{ end }} /> + <label for="{{ printf "%s-%d" $group $index }}"> + {{- $tab.Name -}} + </label> + <div class="tab"> + {{- .Content | markdownify -}} + </div> +{{- end -}} +</div> + |