{{ $currentPage := . }}

<nav id="sidebar">
    <header>
        <img id="avatar" src="/2021_vrifox-avatar.png">
        <p id="name">{{ .Site.Params.displayName }}</p>
        <p id="information">
            <span>{{ .Site.Params.username }}</span>
        </p>
    </header>
    <section id="sidebar-menu">
        <ul>
        {{- range .Site.Menus.main }}
        {{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}
            <li class="active"><a href="{{ .URL }}">{{ i18n .Identifier | default .Name }}</a></li>
        {{ else }}
            <li><a href="{{ .URL }}">{{ i18n .Identifier | default .Name }}</a></li>
        {{ end }}
        {{- end }}
        </ul>
    </section>
    <aside>
    {{- if .Site.IsMultiLingual }}
        {{ $siteLanguages := .Site.Languages }}
        {{ $pageLanguage := .Page.Lang }}
        <div id="language-select">
            <span id="language-icon" href="#" data-page-lang="{{ .Page.Lang }}">🌐</span>
            <ul id="languages">
            {{ range .Page.AllTranslations }}
                {{ $translation := . }}
                {{ range $siteLanguages }}
                    {{ if eq $translation.Lang .Lang }}
                        {{ if eq $pageLanguage .Lang }}
                            <li class="active"><a href="{{ $translation.Permalink }}">{{ .LanguageName }}</a></li>
                        {{ else }}
                            <li><a href="{{ $translation.Permalink }}">{{ .LanguageName }}</a></li>
                        {{ end }}
                    {{ end }}
                {{ end }}
            {{ end }}
            </ul>
        </div>
    {{- end }}
</nav>
