Skip to content

Commit

Permalink
Fix sidebar jump (#31232)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnCuppens committed Jul 3, 2020
1 parent 10690dd commit 7cedb8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
5 changes: 0 additions & 5 deletions site/assets/scss/_sidebar.scss
Expand Up @@ -50,11 +50,6 @@
}
}
}

// Adjust font size and font weights in submenu
+ ul {
@include font-size(.875rem);
}
}

.active {
Expand Down
22 changes: 12 additions & 10 deletions site/layouts/partials/docs-sidebar.html
Expand Up @@ -2,7 +2,7 @@
{{- $url := split .Permalink "/" -}}
{{- $page_slug := index $url (sub (len $url) 2) -}}

<ul class="list-unstyled mb-0">
<ul class="list-unstyled mb-0 pt-1 pb-3">
{{- range $group := .Site.Data.sidebar -}}
{{- $link := $group.title -}}
{{- $link_slug := $link | urlize -}}
Expand All @@ -15,20 +15,22 @@
{{- $group_slug := $group.title | urlize -}}
{{- $is_active_group := eq $.Page.Params.group $group_slug }}

<li class="my-1{{ if $is_active_group }} active{{ end }}">
<li class="mb-1{{ if $is_active_group }} active{{ end }}">
<a class="d-inline-flex align-items-center rounded{{ 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 font-weight-normal 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 }}" class="d-inline-flex align-items-center rounded{{ if $is_active }} active{{ end }}"{{ if $is_active }} aria-current="page"{{ end }}>{{ $doc.title }}</a></li>
{{- end }}
</ul>
<div class="collapse{{ if $is_active_group }} show{{ end }}" id="{{ $group_slug }}-collapse">
<ul class="list-unstyled font-weight-normal pb-1 small">
{{- 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 }}" class="d-inline-flex align-items-center rounded{{ if $is_active }} active{{ end }}"{{ if $is_active }} aria-current="page"{{ end }}>{{ $doc.title }}</a></li>
{{- end }}
</ul>
</div>
{{- end }}
</li>
{{- end }}
Expand Down

0 comments on commit 7cedb8e

Please sign in to comment.