<?php
    get_header();
    $sidebar = is_active_sidebar('sidebar') ? true : false;
    if ( $sidebar ) {
        $args['sizes'] = '(min-width: 1200px) 740px, (min-width: 992px) 560px, (min-width: 768px) 320px, (min-width: 576px) 470px, calc( 100vw - 70px )';
    } else {
        $args['sizes'] = '(min-width: 1200px) 1070px, (min-width: 992px) 890px, (min-width: 768px) 650px, (min-width: 576px) 470px, calc( 100vw - 70px )';
    }
    ?>
    <div class="main-content">
    <?php
        while ( have_posts() )
        {
            the_post();
            ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class( 'kayla-box' ); ?>>
                <div class="post-format post-thumbnails">
                <?php
                    the_post_thumbnail( 'full', $args );
                ?>
                </div>
                <div class="post-details">
                    <?php if ( ! get_theme_mod( 'kayla_post_hide_category' ) ) { ?>
                    <div class="post-cats"><?php the_category(', '); ?></div>
                    <?php
                    }            
                    the_title( '<h1 class="entry-title">', '</h1>' );
                    get_template_part( 'template-parts/post', 'meta' );
                    ?>

                    <div class="entry-content">
                    <?php
                        the_content();
                        wp_link_pages();
                    ?>
                    </div>
    
                    <?php if ( get_the_tags() ) { ?>
                    <div class="tagcloud">
                        <?php the_tags( '',', ' ); ?>
                    </div>
                    <?php } ?>
                </div>
            </article>
            <?php
                if ( get_previous_post_link() || get_next_post_link() ) { ?>
                <div class="single-post-next-prev kayla-box">
                    <?php
                        if ( get_previous_post_link() ) {
							previous_post_link( '%link', '&laquo; ' . __( 'Previous Post', 'kayla' )  );
						}

                        if ( get_next_post_link() ) {
							next_post_link( '%link', __( 'Next Post', 'kayla' ) . ' &raquo;' );
						}
                    ?>
                </div>
                <?php
                }
                get_template_part( 'template-parts/single-post', 'related' );

                // If comments are open or there is at least one comment, load up the comment template.
            	if ( comments_open() || get_comments_number() ) {
            		comments_template( '', true );
            	}
        }
    ?>
    </div>
    <?php
    get_sidebar();
    
    get_footer();
