{{ $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 class="hint-text" href="{{ .URL }}" data-title="{{ i18n .Identifier | default .Name }}">{{ partial "helpers/icons" .Identifier }}</a></li>
                {{ else }}
                    <li><a class="hint-text" href="{{ .URL }}" data-title="{{ i18n .Identifier | default .Name }}">{{ partial "helpers/icons" .Identifier }}</a></li>
                {{ end }}
            {{- end }}
        </ul>
    </section>
    <aside>
        <section id="social-links">
            <a class="hint-text" rel="me" href="https://social.anoxinon.de/@vri" data-title="Mastodon">{{ 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 class="hint-text" id="language" href="{{ $translation.Permalink }}" data-title="{{ .LanguageName }}">{{ .Params.languageFlag }}</a>
                        {{ end }}
                    {{ end }}
                {{ end }}
            {{ end }}
        {{- end }}
        </section>
    </aside>
</nav>
