<section class="section section--page pt-0">
    <div class="container">
        {include file="breadcrumbs.tpl"}
        <div class="section__head mb-md-5 mb-4">
            <h2 class="h2">Блог</h2>
        </div>
        <div class="row g-4 flex-md-row flex-column-reverse">
            <div class="col-lg-9 col-md-8 col-12">
                <div class="row row-cols-lg-3 row-cols-md-2 row-cols-1 g-4">
                    {foreach $posts AS $item}
                        <div class="col">
                            <a href="/blog/{$item->url}" class="blog">
                                <span class="blog__cat-label">{$categories[$item->categories]}</span>
                                <img src="{$item->image|resize:550:370:crop}" alt="" class="blog__picture img-fluid">
                                <span class="blog__content">
                                    <span class="blog__cat">Автор: {$item->author}</span>

                                    <span class="blog__title blog__title--sm">
                                        {$item->name}
                                    </span>

                                    <span class="blog__date">{$item->added|date}</span>
                                </span>
                            </a>
                        </div>
                    {/foreach}
                </div>
            </div>
            <div class="col-lg-3 col-md-4 col-12 d-flex flex-column blog__sidebar">
                <form method="get" action="/blog" class="blog__sidebar-form d-flex flex-column">
                    <input class="blog__sidebar-search form-control" type="text" name="keyword" value="{if !empty($keyword)}{$keyword|escape}{/if}" placeholder="Поиск по статьям">
                    <button type="submit" class="blog__sidebar-button button button-primary justify-content-center">Искать</button>
                </form>
                <div class="blog__sidebar-categories">
                    <h3>Категории</h3>
                    <div class="blog__categories-list">
                        <a href="/blog">Все</a>
                        {foreach $categories AS $url => $name}
                            <a href="/blog?category={$url}">{$name}</a> {if !$name@last}{/if}
                        {/foreach}
                    </div>
                </div>
                <div class="blog__sidebar-tags">
                    <h3>Теги</h3>
                    <div class="blog__tags-list">
                        {foreach $tags AS $t}
                            <a href="/blog?tag={$t}">#{$t}</a>{if !$t@last}{/if}
                        {/foreach}
                    </div>
                </div>
            </div>
        </div>
        {include file='pagination.tpl'}
    </div>
</section>
