<nav class="sidebar d-print-none">
    <div class="spacer"></div>
    <div class="directory" role="tablist">
        {{ $section := .Site.GetPage "section" .Section }}

        {{ $pages := (where .Site.Pages "Section" .Section).ByWeight }}
        {{ $current := . }}

        {{ range $count, $page := $pages }}
            {{ if eq .Parent $section }}

                <div class="card">
                    <div class="card-header" role="tab" id="header{{ $count }}">
                        <a data-toggle="collapse" href="#collapse{{ $count }}" title="{{ $page.Description }}" role="button" aria-controls="collapse{{ $count }}">
                            <div>
                                {{- if $page.Params.icon -}}
                                    {{- partial "icon.html" .Params.icon -}}
                                {{- end -}}
                                {{- $page.Title -}}
                            </div>
                        </a>
                    </div>

                    <div id="collapse{{ $count }}" class="collapse{{if .IsAncestor $current}} show{{end}}" data-parent="#sidebar" role="tabpanel" aria-labelledby="header{{ $count }}">
                        <div class="card-body">
                            {{ partial "sidebar-level.html" (dict "pages" $pages "parent" $page "current" $current "collapse" false) }}
                        </div>
                    </div>
                </div>
            {{ end }}
        {{ end }}

        {{ if not .Site.Data.args.archive }}
            {{ if strings.HasSuffix $section.Dir "blog/" }}
                <div class="text-center subscribe" >
                    <a href="/feed.xml" target="_blank">
                        {{ partial "large_icon.html" "rss" }}{{ i18n "subscribe" }}
                    </a>
                </div>
            {{ end }}
        {{ end }}
    </div>
</nav>
