<?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://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Edify
 */

get_header();

$show_blog_header = get_theme_mod('show_blog_banner',true); 

if($show_blog_header){
	get_template_part( 'template-parts/banner/banner-blog');
}


$tsp_blog_sidebar = get_theme_mod('blog_sidebar','no'); 

$blog_column = is_active_sidebar( 'blog-sidebar' ) ? 8 : 12;
// $blog_column = ( $tsp_blog_sidebar !== 'no' && is_active_sidebar( 'blog-sidebar' ) ) ? 8 : 12;
?>

<div class="page-wrapper">
	<main id="main" class="site-main">
		<div class="container">
			<div class="row justify-content-center">

				<div class="col-xl-<?php print esc_attr( $blog_column );?>  col-lg-<?php print esc_attr( $blog_column );?> col-md-12">
					<div class="row">
						<?php
						if ( have_posts() ) :

							/* Start the Loop */
							while ( have_posts() ) :
								the_post();

								get_template_part( 'template-parts/content', get_post_format() );

							endwhile;

						edify_post_pagination();

						else :

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

						endif;
						?>				

					</div>
					
	
					
				</div>
				
				<?php if ( is_active_sidebar( 'blog-sidebar' ) ): ?>
					<div class="col-lg-4 col-xl-4">
						<div class="blog-sidebar mt-5 mt-lg-0">
							<?php get_sidebar();?>
						</div>
					</div>
				<?php endif;?>
			</div>
		</div>
	</main>
</div>

<?php

get_footer();
