{{> head}}
{{> navbar}}
   <main class="main page page--tag">
      {{#tag}}
         <div class="hero">
            <div class="main__inner">
               <h1>{{name}}
                  {{#if tagViewConfig.displayPostCounter}}
                     <sup>({{postsNumber}})</sup>
                  {{/if}}
               </h1>
               {{#if tagViewConfig.displayDescription}}
                  {{#if description}}
                     {{{description}}}
                  {{/if}}
               {{/if}}
            </div>
         </div>

         {{#if tagViewConfig.displayPostList}}
            <div class="main__inner">
               {{#each ../posts}}
                  <article class="c-card">
                     {{#checkIfAny @config.custom.cardsAuthor @config.custom.cardsDate}}
                        <div class="c-card__meta">
                           {{#if @config.custom.cardsAuthor}}
                              <div class="c-card__author">
                                 {{#author}}
                                    {{#if avatar}}
                                       <img
                                          src="{{avatarImage.url}}" 
                                          {{ lazyload "lazy" }}
                                          height="{{avatarImage.height}}"
                                          width="{{avatarImage.width}}" 
                                          alt="{{avatarImage.alt}}">
                                    {{/if}}
                                    <a href="{{url}}">{{name}}</a>
                                 {{/author}}
                              </div>
                           {{/if}}

                           {{#if @config.custom.cardsDate}}
                              <time datetime="{{date createdAt 'YYYY-MM-DDTHH:mm'}}">
                                 {{#checkIf @config.custom.formatDate '!=' 'custom'}}
                                    {{date createdAt @config.custom.formatDate}}
                                 {{else}}
                                    {{date createdAt @config.custom.formatDateCustom}}
                                 {{/checkIf}}
                              </time>
                           {{/if}}
                           
                        </div>
                     {{/checkIfAny}}

                     {{#if @config.custom.cardsImage}}
                        {{#featuredImage}}
                           {{#if url}}
                              <a href="{{../url}}" class="c-card__image">
                                 <img
                                    src="{{url}}"
                                    {{#if @config.site.responsiveImages}}
                                       {{responsiveImageAttributes 'featuredImage' srcset.cards sizes.cards}}
                                    {{/if}}
                                    {{ lazyload "lazy" }}
                                    height="{{height}}"
                                    width="{{width}}"
                                    alt="{{alt}}">
                              </a>
                           {{/if}}
                        {{/featuredImage}}
                     {{/if}}

                     <header class="c-card__header">
                        <h2 class="c-card__title">
                           <a href="{{url}}">{{title}}</a>
                        </h2>
                        {{#if @config.custom.cardsExcerpt}}
                           {{#if hasCustomExcerpt}}
                              {{{ excerpt }}}
                           {{else}}
                              <p>{{{ excerpt }}}</p>
                           {{/if}}
                        {{/if}}  
                     </header>
                  </article>
               {{/each}}
               {{> pagination}}
            </div>
         {{/if}}
      {{/tag}}
   </main>
{{> sidebar}}
{{> footer}}