<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Blogbuster
 */

$custom_post_class[] = ! has_post_thumbnail() ? 'no-thumbnail' : 'has-thumbnail';

$blogbuster_archive_page_style = blogbuster_get_customizer_option_value( 'blogbuster_archive_page_style' );

if ( 'archive-style--classic' === $blogbuster_archive_page_style ) {
	$thumb_size = 'full';
} else {
	$thumb_size = 'medium';
}

$categories = get_the_category();
if ( !empty( $categories ) ) {
    $category_id = $categories[0]->term_id; // Get the first category ID
    $custom_post_class[]= "post-cat-".$category_id;
}

?>

<article id="post-<?php the_ID(); ?>" <?php post_class( implode( ' ', $custom_post_class ) ); ?>>
	
<div class="single-post-wrap">

	<div class="post-thumbnail-wrap">
        <?php blogbuster_post_thumbnail( $thumb_size ); ?>
    </div>

	<div class="mt-post-content-wrap">
		<?php if ( 'post' === get_post_type() ) : ?>
			<div class="entry-meta">
				<?php
					blogbuster_posted_on();
					blogbuster_posted_by();
				?>
			</div><!-- .entry-meta -->
		<?php endif; ?>
		<header class="entry-header">
			<?php
				if ( is_singular() ) :
					the_title( '<h1 class="entry-title">', '</h1>' );
				else :
					the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
				endif;
			?>	
		</header><!-- .entry-header -->

		<div class="entry-content">
			<?php the_excerpt(); ?>
		</div><!-- .entry-content -->

		<div class="entry-footer">
			<?php blogbuster_entry_footer(); ?>
		</div><!-- .entry-footer -->

		<div class="archive-cat-read-wrap mt-flex">

			<div class="post-cats-wrap">
		        <?php blogbuster_the_post_categories_list( get_the_ID(), 2 ); ?>
		    </div><!-- .post-cats-wrap -->
			
			<?php get_template_part( 'template-parts/partials/post/read', 'more' ); ?>
			
		</div> <!-- archive-cat-read-wrap -->

	</div> <!-- mt-post-content-wrap -->

</div> <!-- single-post-wrap  -->
	
</article><!-- #post-<?php the_ID(); ?> -->