{{ $currentPage := . }}

<nav id="sidebar">
    <header>
        {{ with .Site.Params.avatar }}
            {{ $avatar := resources.Get . }}
            {{ $avatar := $avatar.Resize "64x webp" }}
            <img id="avatar" alt="{{ $.Site.Params.displayName }}" src="{{ $avatar.RelPermalink }}" />
        {{ end }}
    </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>
        <section id="social-links">
            <a rel="me" href="https://social.anoxinon.de/@vri">{{ partial "helpers/icons" "mastodon" }}</a>
        </section>
        <section id="languages">
        {{- if .Site.IsMultiLingual }}
            {{ $siteLanguages := .Site.Languages }}
            {{ $pageLanguage := .Page.Lang }}
    
            {{ range .Page.AllTranslations }}
                {{ $translation := . }}
                {{ range $siteLanguages }}
                    {{ if eq $translation.Lang .Lang }}
                        {{ if ne $pageLanguage .Lang }}
                            <a id="language" href="{{ $translation.Permalink }}">{{ .Params.languageFlag }}</a>
                        {{ end }}
                    {{ end }}
                {{ end }}
            {{ end }}
        {{- end }}
        </section>
    </aside>
</nav>
