<?php
/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Sparta
 */

get_header();
?>
    <section class="vk-content">
        <div class="vk-page blog blog-list">
            <div class="container">
                <div class="row">
                    <?php
                    if (is_active_sidebar('sidebar-1')) :
                        echo '<div class="col-lg-9">';
                    else:
                        echo '<div class="col-lg-12">';
                    endif;

                    if (have_posts()) :
                        if (is_home() && !is_front_page()) : ?>
                            <header>
                                <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
                            </header>
                        <?php
                        endif;

                        while (have_posts()) : the_post();

                            /*
                             * Include the Post-Format-specific template for the content.
                             * If you want to override this in a child theme, then include a file
                             * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                             */
                            ?>
                            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                                <div class="vk-blog-list-item sparta-posts-index">
                                    <?php if (has_post_thumbnail()) : ?>
                                        <div class="vk-img-frame">
                                            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                                                <?php the_post_thumbnail(); ?>
                                            </a>
                                        </div>
                                    <?php endif; ?>

                                    <div class="vk-blog-item-header entry-meta">
                                        <?php Sparta_Helper::sparta_date_meta(); ?>
                                        <div class="vk-blog-item-info">
                                            <header class="entry-header">
                                                <h2 class="vk-title">
                                                    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(esc_html__('Permanent Link to %s', 'sparta'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a>
                                                </h2>
                                            </header>
                                            <?php Sparta_Helper::sparta_vk_post_meta_full(); ?>
                                        </div>
                                    </div>
                                    <div class="brief-content">
                                        <?php the_content(); ?>
                                    </div>
                                    <?php
                                    wp_link_pages(array(
                                            'link_before' => '<span>',
                                            'link_after' => '</span>',
                                            'pagelink' => '%',
                                            'before' => '<div class="blog-pagination uni-pagination-content">',
                                            'after' => '</div>',
                                            'nextpagelink' => esc_html__('&rarr;', 'sparta'),
                                            'previouspagelink' => esc_html__('&larr;', 'sparta'),
                                        )
                                    );

                                    if (has_tag()) :
                                        echo '<div class="vk-divider"></div><div class="vk-post-meta meta-bottom">';
                                            echo '<ul class="vk-list vk-list-inline vk-list-post-meta">';
                                                echo '<li class="tags-links"><i class="vk-icon ti-tag"></i>';
                                                    printf(esc_html__('%1$s', 'sparta'), get_the_tag_list('', ', '));
                                                echo '</li>';
                                            echo '</ul>';
                                        echo ' </div></div>';
                                    endif;
                                    ?>
                            </article>
                        <?php
                        endwhile;
                        Sparta_Helper::sparta_paging_nav();

                    else :
                        get_template_part('template-parts/content', 'none');

                    endif; ?>

                </div>
                <?php if (is_active_sidebar('sidebar-1')) : ?>
                    <div class="col-lg-3">
                        <?php get_sidebar(); ?>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </section>
<?php
get_footer();
