<?php
    get_header();
    $sidebar = is_active_sidebar('sidebar') ? true : false;
    if ( $sidebar ) {
        $args['sizes'] = '(min-width: 1400px) 966px, (min-width: 1200px) 831px, (min-width: 992px) 616px, (min-width: 768px) 396px, (min-width: 576px) 516px, calc( 100vw - 24px )';
    } else {
        $args['sizes'] = '(min-width: 1400px) 1296px, (min-width: 1200px) 1116px, (min-width: 992px) 936px, (min-width: 768px) 696px, (min-width: 576px) 516px, calc( 100vw - 24px )';
    }
    ?>
    <div class="main-content">
    <?php
        while ( have_posts() )
        {
            the_post();
            ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class( 'sarahlist-box' ); ?>>
                <div class="post-format post-thumbnails">
                <?php
                    the_post_thumbnail( 'full', $args );
                ?>
                </div>
                <div class="post-details">
                    <?php if ( ! get_theme_mod( 'sarahlist_post_hide_category' ) ) { ?>
                    <div class="post-cats"><?php the_category(', '); ?></div>
                    <?php
                    }            
                    the_title( '<h1 class="entry-title">', '</h1>' );
                    get_template_part( 'template-parts/post', 'meta' );
                    ?>

                    <div class="entry-content">
                    <?php
                        the_content();
                        wp_link_pages();
                    ?>
                    </div>
    
                    <?php if ( get_the_tags() ) { ?>
                    <div class="tagcloud">
                        <?php the_tags( '',' ' ); ?>
                    </div>
                    <?php } ?>
                </div>
            </article>
            <?php
                if ( get_previous_post_link() || get_next_post_link() ) { ?>
                <div class="single-post-next-prev sarahlist-box">
                    <?php
                        if ( get_previous_post_link() ) {
							previous_post_link( '%link', '&laquo; ' . __( 'Previous Post', 'sarahlist' )  );
						}

                        if ( get_next_post_link() ) {
							next_post_link( '%link', __( 'Next Post', 'sarahlist' ) . ' &raquo;' );
						}
                    ?>
                </div>
                <?php
                }
                get_template_part( 'template-parts/single-post', 'related' );

                // If comments are open or there is at least one comment, load up the comment template.
            	if ( comments_open() || get_comments_number() ) {
            		comments_template( '', true );
            	}
        }
    ?>
    </div>
    <?php
    get_sidebar();
    
    get_footer();
