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

?>
<div class="maincontent">
	<div class="justcontent">
		<header class="pb-3">
			<div class="post-details admin_box flex gap-4">
				<div class="post-details flex">
					<?php $prime_construction_author = get_theme_mod('prime_construction_post_hide_author', false);
					if ($prime_construction_author === false) { ?>
						<i class="fas fa-user me-2 mt-1"></i><span
							class="me-2 entry-by"><?php echo esc_html(get_theme_mod('prime_construction_meta_field_by', 'By')); ?></span><span
							class="entry-author"><a
								href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>"><?php the_author(); ?><span
									class="screen-reader-text"><?php the_author(); ?></span></a></span>
					<?php } ?>
				</div>
				<div class="flex">
					<?php $prime_construction_date = get_theme_mod('prime_construction_post_hide_date', false);
					if ($prime_construction_date === false) { ?>
						<i class="fas fa-calendar-alt me-2 mt-1"></i><span class="entry-date"><a
								href="<?php echo esc_url(get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'))); ?>"><?php echo esc_html(get_the_date()); ?><span
									class="screen-reader-text"><?php echo esc_html(get_the_date()); ?></span></a></span>
					<?php } ?>
				</div>
				<div class="flex">
					<?php $prime_construction_comment = get_theme_mod('prime_construction_post_comments', false);
					if ($prime_construction_comment === false) { ?>
						<i class="fas fa-comments me-2 mt-1"></i><span
							class="entry-comments"><?php comments_number(__('0 Comment', 'prime-construction'), __('0 Comments', 'prime-construction'), __('% Comments', 'prime-construction')); ?>
						</span>
					<?php } ?>
				</div>

			</div>
			<h2 class="page-title mb-0">
				<?php
				// Wrap the post title in an anchor tag linking to the post
				echo '<a href="' . esc_url(get_permalink()) . '">' . esc_html(get_the_title()) . '</a>';
				?>
			</h2>

		</header>
		<!-- </?php the_content(); ?> -->
		<p><?php
		// Set a word limit, e.g., 40 words
		$content_limit = 40;

		// Get the content and trim it
		echo wp_trim_words(get_the_content(), $content_limit, '...');
		?></p>
		<button>
			<a class="readbtn" href="<?php echo esc_url(get_permalink()); ?>"><?php echo esc_html(get_theme_mod('prime_construction_read_more_text', 'Read More')); ?><i class="fa-solid fa-arrow-right"></i></a>
		</button>
	</div>

</div>