<?php
get_header();

if (is_front_page() && is_home()) { ?>
<?php
    /**
     * Template Name: Custom Front Page
     */

    get_header(); ?>
<main id="primary" class="site-main">
    <?php 
        $eco_solar_energy_header_image1 = get_theme_mod('eco_solar_energy_header_image1');                    
        if(!empty($eco_solar_energy_header_image1)) {  ?>
    <div class="banner-head" style="background-image: url('<?php echo esc_url($eco_solar_energy_header_image1)?>');">
        <div class="center-div">
            <h1><?php esc_html_e('Posts', 'eco-solar-energy'); ?></h1>
        </div>
    </div>;
    <?php } else{?>
    <div class="banner-head"
        style="background-image: url('<?php echo esc_url( get_template_directory_uri() . '/assets/images/sliderimg6.png' ); ?>');">
        
        <div class="center-div">
            <h1><?php esc_html_e('Posts', 'eco-solar-energy'); ?></h1>
        </div>
    </div>;
    <?php }?>
    <div class="blog-div container-fluid p-5 front">
        <div class="row">
            <div class="col-lg-9 col-md-8 col-12 p-5">
                <?php
                    if (have_posts()) :

                        if (is_home() && !is_front_page()) :
                            ?>
                <header>
                    <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
                </header>
                <?php
                        endif;

                        /* Start the Loop */
                        while (have_posts()) :
                            the_post();
                            ?>
                <div class="row mainrow" id="primaryid">
                    <div class="col-lg-12">
                        <?php
                                            get_template_part( 'template-parts/maincontent', get_post_type() );
                                                ?>
                    </div>
                </div>
                <?php
                            		
                          endwhile;
                        // Add pagination instead of navigation
                        the_posts_pagination(array(
                            'mid_size'  => 2, // Number of page links to show on either side of the current page
                            'prev_text' => __('« Previous', 'eco-solar-energy'),
                            'next_text' => __('Next »', 'eco-solar-energy'),
                        ));
                    
                    else :

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

                    endif;
                    ?>
            </div>
            <div class="col-lg-3 col-md-4 col-12 sidebar-col">
                <div class="sidebar-div">
                    <?php
                        
                        if (is_active_sidebar('sidebar-1')) {
                            dynamic_sidebar('sidebar-1');                            
                        } else {
                            get_sidebar();
                        }
                        ?>
                </div>
            </div>
        </div>
    </div>
</main>

<?php get_footer(); ?>

<?php } elseif (is_front_page() && !is_home()) { ?>
<main id="primary" class="site-main">
    <?php
        get_template_part('template-parts/customizesection/front', 'home');

        get_template_part('template-parts/customizesection/front', 'about');

        get_template_part('template-parts/customizesection/front', 'service');
        ?>
</main><!-- #main -->
<?php }

get_footer();
?>