0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-02 14:24:19 +01:00
Bootstrap/site/layouts/partials/docs-sidebar.html
XhmikosR d2325b65c8
Improve docs-sidebar.html (#30567)
Reduce the output HTML
2020-04-17 18:47:19 +02:00

44 lines
1.7 KiB
HTML

<nav class="collapse bd-links" id="bd-docs-nav" aria-label="Docs navigation">
{{- $url := split .Permalink "/" -}}
{{- $page_slug := index $url (sub (len $url) 2) -}}
<ul class="list-unstyled mb-0">
{{- range $group := .Site.Data.sidebar -}}
{{- $link := $group.title -}}
{{- $link_slug := $link | urlize -}}
{{- if $group.pages -}}
{{- $link = index $group.pages 0 -}}
{{- $link_slug = $link.title | urlize -}}
{{- end -}}
{{- $group_slug := $group.title | urlize -}}
{{- $is_active_group := eq $.Page.Params.group $group_slug }}
<li class="my-1{{ if $is_active_group }} active{{ end }}">
<a class="{{ if not $is_active_group }}collapsed{{ end }}" data-toggle="collapse" href="#{{ $group_slug }}-collapse" role="button" aria-expanded="{{ $is_active_group }}"{{ if $is_active_group }} aria-current="true"{{ end }}>
{{ $group.title }}
</a>
{{- if $group.pages }}
<ul class="list-unstyled mb-2 collapse{{ if $is_active_group }} show{{ end }}" id="{{ $group_slug }}-collapse">
{{- range $doc := $group.pages -}}
{{- $doc_slug := $doc.title | urlize -}}
{{- $is_active := and $is_active_group (eq $page_slug $doc_slug) -}}
{{- $href := printf "/docs/%s/%s/%s/" $.Site.Params.docs_version $group_slug $doc_slug }}
<li><a href="{{ $href }}"{{ if $is_active }} class="active" aria-current="page"{{ end }}>{{ $doc.title }}</a></li>
{{- end }}
</ul>
{{- end }}
</li>
{{- end }}
<li class="my-3 mx-4 border-top"></li>
<li{{ if eq $page_slug "migration" }} class="active"{{ end }}>
<a href="/docs/{{ $.Site.Params.docs_version }}/migration/">
Migration
</a>
</li>
</ul>
</nav>