<?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 wpstream-theme
 */

get_header();
?>
	<div id="content" class="site-content py-5 mt-4 <?php echo esc_attr( wpstream_theme_container_class() ); ?>">
		<div id="primary" class="content-area">

			<!-- Hook to add something nice -->
			<?php wpstream_bs_after_primary(); ?>

			<main id="main" class="site-main">

				<!-- Header -->
				<div class="py-3 py-md-5 text-center">
					<h1 class="display-1"><?php bloginfo( 'name' ); ?></h1>
					<p class="lead"><?php bloginfo( 'description' ); ?></p>
				</div>

				<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
					<!-- Post List -->
					<div class="row">
						<div class="col col-md-8 col-lg-9 row wpstream-grid-container">

							<!-- Grid Layout -->
							<?php
							if ( class_exists( 'Wpstream_Player' ) ) {
								$card_grid_class_overwrite = wpstream_video_cards_column_class( 0 );
							} else {
								$card_grid_class_overwrite = wpstream_blog_cards_column_class( 0 );
							}
							if ( have_posts() ) :
								while ( have_posts() ) :
									the_post();

									include get_template_directory() . '/template-parts/single/cards/blog-card-v1.php';

								endwhile;
							endif;
							?>

							<footer class="entry-footer">
								<?php wpstream_theme_pagination(); ?>
							</footer>

						</div>
						<!-- col -->
						<?php get_sidebar(); ?>
					</div>
					<!-- row -->
				<?php else : ?>
					<div class="row wpstream-grid-container">
						<!-- Grid Layout -->
						<?php
						if ( class_exists( 'Wpstream_Player' ) ) {
						    $card_grid_class_overwrite = wpstream_video_cards_column_class( 0 );
						} else {
							$card_grid_class_overwrite = wpstream_blog_cards_column_class( 0 );
						}
						if ( have_posts() ) :
							?>
							<?php while ( have_posts() ) : ?>
								<?php the_post(); ?>

								<?php include get_template_directory() . '/template-parts/single/cards/blog-card-v1.php'; ?>

						<?php endwhile; ?>
						<?php endif; ?>


						<footer class="entry-footer">
							<?php wpstream_theme_pagination(); ?>
						</footer>
					</div>
				<?php endif; ?>
			</main><!-- #main -->

		</div><!-- #primary -->
	</div><!-- #content -->
<?php
get_footer();
