<?php
get_header();
?>

<main id="primary-main" class="site-main singlepage">
	<?php
	$banner_img = get_the_post_thumbnail_url( get_the_ID(), 'full' );

	// If no image, use default image from theme folder
	if ( empty( $banner_img ) ) {
		$banner_img = get_template_directory_uri() . '/assets/images/default-banner.jpg';
	}
	?>

	<div class="banner-head"
	     style="background-image: url('<?php echo esc_url( $banner_img ); ?>'); width:100%; background-size:cover;">
		<header class="entry-header">
			<h1 class="entry-title text-center">
				<?php the_title(); ?>
			</h1>
		</header>
	</div>

	<div class="container d-flex mt-5 mb-5 max-w-7xl mx-auto" style="padding-top:5rem;">

		<div class="col-lg-8 col-12 postcontent">
			<main id="primary" class="site-main">

				<?php
				if ( have_posts() ) :

					if ( is_home() && ! is_front_page() ) :
						?>
						<header>
							<h1 class="page-title screen-reader-text">
								<?php single_post_title(); ?>
							</h1>
						</header>
						<div class="gap-8">
						<?php
					endif;

					while ( have_posts() ) :
						the_post();
						get_template_part( 'template-parts/maincontent', get_post_type() );
					endwhile;

					the_posts_navigation();

				else :
					get_template_part( 'template-parts/content', 'none' );
				endif;
				?>

			</main><!-- #primary-main -->
		</div>

		<div class="col-lg-4 col-12 postsidebar">
			<?php get_sidebar(); ?>
		</div>

	</div><!-- .container -->

</main><!-- #primary -->

<?php
get_footer();
