<?php
/**
 * The template for displaying all single posts.
 *
 * @package Reach
 * @global $options
 */

use Reach\App\Posts\BlogPosts;
use Reach\App\Theme\ThemeStyles;
use Reach\App\Fields\SiteOptions;

// get site options
$options = SiteOptions::getSiteOptions();
$background = $options['body_background']['background_color'];
$color_contrast   = ThemeStyles::colorLightOrDark( $background , 'dark', 'light' );

get_header();

// get page header markup
get_template_part( 'components/page', 'header' );
?>

    <div class="container">
        <div class="blog__layout blog__layout--default <?php echo 'text--' . $color_contrast; ?>">
            <div class="blog__posts">
                <?php
                while ( have_posts() ) {
                    the_post();

                    // Loads the content/singular/page.php template.
                    get_template_part( 'content/singular/' . get_post_type() );

                    // If comments are open or we have at least one comment, load up the comment template.
                    if ( comments_open() || get_comments_number() ) :
                        comments_template();
                    endif;
                }

                // output post navigation links
                BlogPosts::getPostNextPreviousLinks();

                // Get related articles for the current post.
                BlogPosts::getRelatedArticles( get_the_ID() );
                ?>
            </div>

            <?php get_sidebar(); ?>
        </div>
    </div>

<?php
$blog_page = get_option( 'page_for_posts' );

// Loads the interior page modules
do_action( 'reach/modules/output', $blog_page );

get_footer();