mirror of https://github.com/crossplane/docs.git
new hugo shortcodes to generate docs tabs
Signed-off-by: Pete Lumbis <pete@upbound.io>
This commit is contained in:
parent
f81e633169
commit
f0b844802c
|
@ -0,0 +1,13 @@
|
|||
{{ if .Parent }}
|
||||
|
||||
{{ $tab_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" $tab_name "Content" (.Inner | htmlUnescape | safeHTML) ) }}
|
||||
|
||||
{{ else }}
|
||||
{{ errorf "%q: 'tab' shortcode must be inside 'tabs' shortcode" .Page.File.Path }}
|
||||
{{ end }}
|
|
@ -0,0 +1,25 @@
|
|||
{{- if .Inner -}}{{ end -}}
|
||||
{{- $id := .Get 0 -}}
|
||||
{{- $group := printf "tabs-%s" $id -}}
|
||||
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
{{- range $index, $tab := .Scratch.Get $group -}}
|
||||
{{- $expand := true -}}
|
||||
{{- if $index -}}
|
||||
{{- $expand := false -}}
|
||||
{{- end -}}
|
||||
<li class="{{ if not $index -}}active{{end}}">
|
||||
<a href="#{{$tab.Name | anchorize}}" data-toggle="tab" aria-expanded="{{$expand}}">{{$tab.Name}}</a>
|
||||
</li>
|
||||
{{- end -}}
|
||||
</ul>
|
||||
<br />
|
||||
<div class="tab-content">
|
||||
{{- range $index, $tab := .Scratch.Get $group -}}
|
||||
<div class="tab-pane fade {{ if not $index}}active in{{end}}" id="{{$tab.Name | anchorize}}">
|
||||
{{- .Content | safeHTML | $.Page.RenderString -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
<p><br /></p>
|
Loading…
Reference in New Issue