<?php
/**
 * Template part for displaying featured post on blog page
 *
 * @package shop-zen
 */

$categories       = get_the_category();
$category         = ! empty( $categories ) ? $categories[0] : null;
$reading_time     = shop_zen_estimated_reading_time( get_the_content() );
?>

<!-- Featured Post -->
<a href="<?php the_permalink(); ?>" class="featured-post">
    <div class="featured-post-media">
        <?php if ( has_post_thumbnail() ) : ?>
        <img class="featured-image" src="<?php echo esc_url( get_the_post_thumbnail_url( get_the_ID(), 'large' ) ); ?>" alt="<?php echo esc_attr( get_the_title() ); ?>" loading="eager">
        <?php else : ?>
        <div class="featured-image featured-image-placeholder"></div>
        <?php endif; ?>
    </div>
    <div class="featured-content">
        <div class="featured-meta">
            <span class="featured-category"><?php esc_html_e( 'Featured', 'shop-zen' ); ?></span>
            <span class="featured-date"><?php echo esc_html( get_the_date() ); ?> &bull; <?php echo esc_html( $reading_time ); ?> <?php esc_html_e( 'min', 'shop-zen' ); ?></span>
        </div>
        <h2 class="featured-title"><?php the_title(); ?></h2>
        <p class="featured-excerpt"><?php echo wp_trim_words( get_the_excerpt(), 22, '...' ); ?></p>
        <span class="featured-read"><?php esc_html_e( 'Read Article', 'shop-zen' ); ?> &rarr;</span>
    </div>
</a>
