{{ $s := .Site.Params }}
<aside class="sidebar">
  <section class="sidebar_inner">
    <div class="intro">
      <h2>{{ .Site.Title }}</h2>
      <p>{{ $s.IntroDescription }}</p>
      <a href='{{ absLangURL "about/" }}' class="button mt-1" role="button">About This Site</a>
    </div>

    {{ partial "subscriber-form" . }}
    
    {{- $posts := where (where .Site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" $s.mainSections }}
    {{- $featured := default 8 $s.numberOfFeaturedPosts }}
    {{- with first $featured (where $posts "Params.featured" true)}}
    <h2 class="widget-title mt-4" style="font-size: 1.4rem;">{{ i18n "featured_posts" }}</h2>
    <ul>
      {{- range . }}
      <li>
        <a href="{{ .Permalink }}" class="nav-link">{{ .Title }}</a>
      </li>
      {{- end }}
    </ul>
    {{- end }}
    <!-- <h2 class="widget-title mt-4">{{ i18n "recent_posts" }}</h2>
    <ul class="flex-column">
      {{- $recent := default 8 $s.numberOfRecentPosts }}
      {{- range first $recent $posts }}
      <li>
        <a href="{{ .Permalink }}" class="nav-link">{{ .Title }}</a>
      </li>
      {{- end }}
    </ul> -->
    {{- $tagsLimit := $s.numberOfTagsShown }}
    {{- range $key, $value := .Site.Taxonomies }}
    {{- if gt $value 0 }}
    <div>
      <h2 class="widget-title mt-4 taxonomy" id="{{ $key }}-section">{{ i18n $key }}</h2>
      <nav class="tags_nav">
        {{- $onPageTags := $.Page.Params.tags }}
        {{- $slicedTags := ($value.ByCount | first $tagsLimit) }}
        {{- range $slicedTags }}
        <a href='{{ absLangURL $key }}/{{ (replace .Name "#" "%23") | urlize }}/' class="post_tag button button_translucent">
          {{ upper .Name }}
          <span class="button_tally">{{ .Count }}</span>
        </a>
        {{ end }}
        {{ if gt (len $value.ByCount) $tagsLimit }}
        <br>
        <div class="post_tags_toggle button">{{ printf "all_%s" $key | i18n }}</div>
        {{- $tagsInfo := newScratch }}
        <div class="post_tags">
          <div class="tags_list">
            {{- range $value.Alphabetical }}
            {{ $tagsInfo.Add "tagsInfo" (slice .Name .Count)}}
            <a href='{{ absLangURL $key }}/{{ (replace .Name "#" "%23") | urlize }}/' class=" post_tag button button_translucent" data-position={{ .Count }}>
              {{- upper .Name -}}
              <span class="button_tally">{{ .Count }}</span>
            </a>
            {{ end }}
            <div class="tags_sort"><span title="sort alphabetically">[A~Z]</span><span title="sort by count">[0~9]</span>
            </div>
            <span class="tags_hide"><svg class="icon">
            <use xlink:href="#closeme"></use>
          </svg></span>
          </div>
        </div>
        {{- end }}
      </nav>
    </div>
    {{- end }}
    {{- end }}
  </section>
</aside>
