<?php
/**
 * Front Page Template
 *
 * @package computer-repair-solutions
 */

get_header();

if ( is_front_page() && is_home() ) :
	?>

	<main id="primary-main" class="site-main front">
		<?php
		$banner_img = get_the_post_thumbnail_url( get_the_ID(), 'full' );

		if ( empty( $banner_img ) ) {
			$banner_img = get_template_directory_uri() . '/assets/images/default-banner.jpg';
		}
		?>

		<div class="banner-head" style="background-image: url('<?php echo esc_url( $banner_img ); ?>');width: 100%;background-size: cover;">
			<div class="center-div">
				<h1><?php esc_html_e( 'Posts', 'computer-repair-solutions' ); ?></h1>
			</div>
		</div>

		<div class="blog-div container p-2 mt-3" id="primary">
			<div class="row">
				<div class="col-lg-8 col-md-8 col-12 front-post">
					<?php
					if ( have_posts() ) :
						?>
						<div class="row mainrow">
							<?php
							while ( have_posts() ) :
								the_post();
								?>
								<div class="col-lg-12 col-md-12 col-12 box gap-10">
									<?php get_template_part( 'template-parts/maincontent', get_post_type() ); ?>
								</div>
								<?php
							endwhile;

							the_posts_pagination(
								array(
									'mid_size'  => 2,
									'prev_text' => esc_html__( '« Previous', 'computer-repair-solutions' ),
									'next_text' => esc_html__( 'Next »', 'computer-repair-solutions' ),
								)
							);
					else :
						get_template_part( 'template-parts/content', 'none' );
					endif;
					?>
						</div>
				</div>
				<div class="col-lg-4 col-md-4 col-12 sidebar-col">
					<div class="sidebar-div mx-3">
						<?php
						if ( is_active_sidebar( 'sidebar-1' ) ) {
							dynamic_sidebar( 'sidebar-1' );
						} else {
							get_sidebar();
						}
						?>
					</div>
				</div>
			</div>
		</div>
	</main>

<?php else : ?>

	<main id="primary-main" class="site-main">
		<?php
		get_template_part( 'template-parts/section/section', 'featured-slider' );
		get_template_part( 'template-parts/section/section', 'featured-about' );
		get_template_part( 'template-parts/section/section', 'featured-services' );
		?>
	</main><!-- #main -->

<?php
endif;

get_footer();