<?php
get_header();
$args = array();
$sidebar = is_active_sidebar('sidebar') ? true : false;
if ( $sidebar ) {
    $args['sizes'] = '(min-width: 1200px) 335px, (min-width: 992px) 245px, (min-width: 768px) 320px, (min-width: 576px) 470px, calc( 100vw - 70px )';
} else {
    $args['sizes'] = '(min-width: 1200px) 500px, (min-width: 992px) 410px, (min-width: 768px) 650px, (min-width: 576px) 470px, calc( 100vw - 70px )';
}
?>
<div class="main-content">
<?php
    if ( have_posts() ) { ?>
        <div class="kayla-blog blog-grid">
            <?php while ( have_posts() ) { ?>
                <?php the_post(); ?>
                <article <?php post_class( 'kayla-box' ); ?>>
                    <?php
                        $image_url = wp_get_attachment_url( get_post_thumbnail_id() );
                        if ( $image_url ) {
                            ?>
                            <div class="post-thumbnails">
                                <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'full', $args ); ?></a>
                            </div>
                            <?php
                        }
                    ?>
                    <div class="post-details">
                        <div class="post-cats"><?php the_category(', '); ?></div>
                        <?php if ( get_the_title() ) { ?>
                        <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                        <?php } ?>
                        <div class="entry-meta">
                            <a class="post-date" href="<?php the_permalink(); ?>"><?php echo get_the_date(); ?></a>
                        </div>
                        <div class="entry-excerpt">
                            <?php echo wp_trim_words( get_the_excerpt(), 30, '...' ); ?>
                        </div>
                    </div>
                </article>
            <?php } ?>
        </div><?php
        kayla_site_pagination();
    } else {
        get_template_part( 'template-parts/post', 'none' );
    }
    ?>
</div>
<?php

get_sidebar();

get_footer();
