<?php
    get_header();
    
    $sidebar = false; $cols = 'col';
    if ( is_active_sidebar('sidebar') && ! get_theme_mod('loza_blog_hide_sidebar') ) {
        $sidebar = true;
    }
    
    if ( $sidebar ) {
        $cols = 'col-md-7 col-lg-8 col-xl-9';
    }
    
    $blog_class = $sidebar ? 'has-sidebar' : 'no-sidebar';
    
    if ( $sidebar ) {
        $args['sizes'] = '(min-width: 1400px) 966px, (min-width: 1200px) 831px, (min-width: 992px) 616px, (min-width: 768px) 396px, (min-width: 576px) 516px, calc( 100vw - 24px )';
    } else {
        $args['sizes'] = '(min-width: 1400px) 1296px, (min-width: 1200px) 1116px, (min-width: 992px) 936px, (min-width: 768px) 696px, (min-width: 576px) 516px, calc( 100vw - 24px )';
    }
    $blog_class = $sidebar ? '' : ' no-sidebar';
    ?>
    <div class="loza-blog<?php echo esc_attr( $blog_class ); ?>">
        <div class="row">
            <div class="<?php echo esc_attr( $cols ); ?>">
                <div class="single-post-inner">
                <?php
                    while ( have_posts() ) {
                        the_post();
                        ?>
                        <article id="post-<?php the_ID(); ?>" <?php post_class( 'post-large' ); ?>>
                            <?php
                                the_post_thumbnail( 'full', $args );
                            ?>
                            <div class="post-details loza-box">
                                <?php if ( ! get_theme_mod( 'loza_post_hide_category' ) ) { ?>
                                <div class="cat-links"><?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 loza-box">
                                <?php
                                    if ( get_previous_post_link() ) {
        								previous_post_link( '%link', '&laquo; ' . __( 'Previous Post', 'loza' )  );
        							}
        
                                    if ( get_next_post_link() ) {
        								next_post_link( '%link', __( 'Next Post', 'loza' ) . ' &raquo;' );
        							}
                                ?>
                            </div>
                            <?php
                            }
                            get_template_part( 'template-parts/single-post', 'related', $args );
            
                            // 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>
            </div>    
            <?php if ( $sidebar ) { ?>
            <div class="col-md-5 col-lg-4 col-xl-3">
                <?php get_sidebar(); ?>
            </div>
            <?php } ?>
        </div>
    </div>
    <?php
    get_footer();
