<?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 WordPress
 * @subpackage NeatNote
 * @since 1.0.0
 */

get_header();
?>

<?php
$neatnote_hero_banner_heading = get_theme_mod('neatnote_blog_banner_title');
$neatnote_hero_banner_description = get_theme_mod('neatnote_blog_banner_description');
$neatNoteBannerImage = get_theme_mod('neatnote_blog_banner_image');
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <section id="mainContent" class="NeatNote-BannerSection neatnote_bg NeatNote-text-center NeatNote-BannerViewport NeatNote-altBg neatnote_overlay" <?php echo $neatNoteBannerImage ? 'style="background-image: url(' . esc_url($neatNoteBannerImage) . ');"' : 'style="background: var(--primary);"'; ?>>
        <div class="NeatNote-BannerMain">
            <div class="NeatNote-wrapper">
                <div class="NeatNote-BannerContentMain">
                    <h1>
                        <?php if ($neatnote_hero_banner_heading): ?>
                        <?php echo esc_html(sprintf(__('%s', 'neatnote'), $neatnote_hero_banner_heading));
                        else:
                            echo esc_html(__('Our Blog', 'neatnote'));
                        endif; ?>
                    </h1>
                    <?php if ($neatnote_hero_banner_description): ?>
                        <div class="NeatNote-BannerContent NeatNote-fontWhite NeatNote-pt20">
                        <h5><?php echo esc_html(sprintf(__('%s', 'neatnote'), $neatnote_hero_banner_description)); ?></h5>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </section>

    <section class="NeatNote-BlogListingSection NeatNote-p70-0">
        <div class="NeatNote-wrapper">
            <?php if (is_active_sidebar('neatnote-sidebar-blog-page')): ?>
                <div class="neatnote-page-main-content">
                <?php endif; ?>
                <div class="NeatNote-relatedBlogSectionInner <?php echo is_active_sidebar('neatnote-sidebar-blog-page') ? 'neatnoteTwoColmnSec NeatNote-w70' : ''; ?>">
                    <div class="NeatNote-relatedBlogRow ">
                        <?php if (have_posts()): ?>
                            <?php while (have_posts()):
                                the_post(); ?>
                                <?php get_template_part('template-parts/content/related-blog', 'box'); ?>
                            <?php endwhile; ?>
                    </div>
                    <?php if (is_paged() || paginate_links()) : ?>
                        <div class="NeatNote-paginationparent NeatNote-pt100">
                            <?php neatnote_the_posts_navigation(); ?>
                        </div>
                    <?php endif; ?>
                </div>
                <?php if (is_active_sidebar('neatnote-sidebar-blog-page')): ?>
                    <div class="neatnote-page-sidebar-inner NeatNote-w30">
                        <?php dynamic_sidebar('neatnote-sidebar-blog-page'); ?>
                    </div>
                </div>
            <?php endif; ?>
        <?php else: ?>
            <?php get_template_part('template-parts/content/content', 'none'); ?>
        <?php endif; ?>
        </div>
    </section>
</article>
<?php
get_footer();
