<?php

/**
 * The template for displaying archive pages
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package WordPress
 * @subpackage NeatNote
 * @since 1.0.0
 */

get_header();
$thumbnail_url = esc_url(get_the_post_thumbnail_url(get_the_ID(), 'full'));
$static_bg_image = esc_url(get_theme_mod('neatnote_blog_banner_image'));
$default_bg_image = $thumbnail_url ? $thumbnail_url : $static_bg_image;
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php if (have_posts()): ?>
        <section id="mainContent"
            class="NeatNote-BannerSection neatnote_bg NeatNote-text-center NeatNote-BannerViewport NeatNote-altBg neatnote_overlay"
            style="<?php echo $default_bg_image ? "background-image: url('{$default_bg_image}'); background-size: cover; background-repeat: no-repeat;" : "background-color: var(--primary);"; ?>">
            <div class="NeatNote-BannerMain">
                <div class="NeatNote-wrapper">
                    <div class="NeatNote-BannerContentMain">
                        <h1 class="neatnote-page-title"><?php the_title(); ?></h1>
                    </div>
                </div>
            </div>
        </section>

        <section class="NeatNote-BlogListingSection NeatNote-p70-0">
            <div class="NeatNote-wrapper <?php echo is_active_sidebar('neatnote-sidebar-for-pages') ? 'neatnote-page-main-content' : ''; ?>">
                <div class="pageContentInner <?php echo is_active_sidebar('neatnote-sidebar-for-pages') ? ' NeatNote-w70' : ''; ?>">
                    <?php the_content(); ?>
                </div>
                <?php if (is_active_sidebar('neatnote-sidebar-for-pages')): ?>
                    <div class="neatnote-page-sidebar-inner NeatNote-w30">
                        <?php dynamic_sidebar('neatnote-sidebar-for-pages'); ?>
                    </div>
                <?php endif; ?>
            </div>
        </section>
    <?php else: ?>
        <?php get_template_part('template-parts/content/content', 'none'); ?>
    <?php endif; ?>

    <!-- Blog Comment Section -->
    <?php if (comments_open() || get_comments_number()) : ?>
        <section class="CommentSection neatnote-p30-0">
            <div class="CommentParent">
                <div class="NeatNote-wrapper">
                    <div class="comments_container">
                        <?php
                        if (comments_open() || get_comments_number()) {
                            comments_template();
                        }
                        ?>
                    </div>
                </div>
            </div>
        </section>
    <?php endif; ?>
</article>

<?php get_footer(); ?>
