<?php

/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package WordPress
 * @subpackage NeatNote
 * @since 1.0.0
 */

?>
<div class="neatNote-relatedBlogCard">
	<?php
	$featured_img_url = get_the_post_thumbnail_url(get_the_ID(), 'full');
	$post_excerpt = wp_trim_words(get_the_content(), 30, '...');
	$post_url = get_permalink();
	$published_day = get_the_date('j');
	$published_year = get_the_date('Y');
	$published_month = get_the_date('F');

	?>
	<a class="neatNoteBlogFeatureImage" href="<?php echo esc_url($post_url); ?>">
		<div class="neatNote-relatedBlogFeaturdImage neatnote_bg"
			<?php echo $featured_img_url ? 'style="background-image: url(' . esc_url($featured_img_url) . ');"' : 'style="background:var(--accent-color);"'; ?>>
		</div>
	</a>
	<?php if ($published_day || $published_year || $published_month): ?>
		<div class="neatNote-relatedBlogCardDate" data-aos="flip-right">
			<?php if ($published_month): ?>
				<div class="neatNote-blogCardMonth">
					<p><?php echo esc_html(sprintf(__('%s', 'neatnote'), $published_month)); ?></p>
				</div>
			<?php endif; ?>
			<?php if ($published_day): ?>
				<div class="neatNote-blogCardDate">
					<h3><?php echo esc_html(sprintf(__('%s', 'neatnote'), $published_day)); ?></h3>
				</div>
			<?php endif; ?>
			<?php if ($published_year): ?>
				<div class="neatNote-blogCardYear">
					<p><?php echo esc_html(sprintf(__('%s', 'neatnote'), $published_year)); ?></p>
				</div>
			<?php endif; ?>
		</div>
	<?php endif; ?>
	<div class="neatNote-relatedBlogBottomTextContent neatnote-pt30" data-aos="fade-up">
		<div class="neatNote-relatedBlogCardHeading neatnote_equal_title">
			<h5><a href="<?php echo esc_url($post_url); ?>"><?php the_title(); ?></a></h5>
		</div>
		<div class="NeatNote-BlogContentsTop neatnote_equal_content">
			<div class="NeatNote-BlogContents neatnote-pt15">
				<p class="normal neatnote-font16 neatnote-lh87"><?php echo wp_kses_post($post_excerpt); ?></p>
			</div>
		</div>
	</div>
	<div class="NeatNote-ReadMoreButton neatnote-pt15" data-aos="fade-up">
		<a href="<?php echo esc_url($post_url); ?>" class="neatnote-font20 neatnote-lh1 NeatNote-semibold"><?php esc_html_e('Read More', 'neatnote'); ?>
			<span class="NeatNote-BtnArrow"><i class="fa-solid fa-arrow-right"></i></span>
		</a>
	</div>
</div>