<?php
/**
 * The template for displaying static pages
 *
 * @package Blog_Over
 */

get_header();

// Page Layout (from Page Settings)
$layout = get_theme_mod('blog_over_page_layout', 'right-sidebar');
$has_sidebar = ($layout !== 'full-width');
$sidebar_position = ($layout === 'left-sidebar') ? 'left' : 'right';

// Page Content Width (applies to all layouts)
$content_width = get_theme_mod('blog_over_page_content_width', 'default');
$content_width_class = 'content-width-' . $content_width;

// Container Style
$container_style = get_theme_mod('blog_over_page_container_style', 'default');
$container_style_class = 'container-style-' . $container_style;
?>

<main id="primary" class="blog-over-site-main blog-over-page-main">
    <div class="blog-over-page-header-container">
        <?php blog_over_page_header(); ?>
    </div>
    <?php if (blog_over_should_render_breadcrumb_container()): ?>
        <div class="blog-over-breadcrumb-container">
            <?php blog_over_breadcrumb(); ?>
        </div>
    <?php endif; ?>

    <div class="blog-over-container <?php echo esc_attr($content_width_class . ' ' . $container_style_class); ?>">
        <div
            class="blog-over-content-wrapper <?php echo esc_attr($has_sidebar ? 'has-sidebar sidebar-' . $sidebar_position : 'no-sidebar'); ?>">

            <?php if ($has_sidebar && $sidebar_position === 'left'): ?>
                <aside class="blog-over-sidebar">
                    <?php get_sidebar(); ?>
                </aside>
            <?php endif; ?>

            <div class="blog-over-main-content blog-over-page-content-wrapper">
                <?php
                while (have_posts()):
                    the_post();
                    get_template_part('template-parts/content', 'page');
                endwhile;
                ?>
            </div>

            <?php if ($has_sidebar && $sidebar_position === 'right'): ?>
                <aside class="blog-over-sidebar">
                    <?php get_sidebar(); ?>
                </aside>
            <?php endif; ?>

        </div>
    </div>
</main>

<?php
get_footer();
