<?php
/**
 * Template part for displaying posts in archive/blog pages
 *
 * @package Paws_And_Care
 * @since 1.0.0
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class( 'blog-card card h-100' ); ?>>
    <?php if ( has_post_thumbnail() ) : ?>
        <a href="<?php the_permalink(); ?>">
            <?php the_post_thumbnail( 'large', array( 'class' => 'card-img-top' ) ); ?>
        </a>
    <?php endif; ?>

    <div class="card-body">
        <div class="d-flex align-items-center mb-3">
            <?php
            $categories = get_the_category();
            if ( ! empty( $categories ) ) :
                ?>
                <span class="badge bg-primary me-2"><?php echo esc_html( $categories[0]->name ); ?></span>
            <?php endif; ?>
            <small class="text-muted">
                <i class="fa-regular fa-calendar me-1"></i> <?php echo esc_html( get_the_date() ); ?>
            </small>
        </div>

        <?php the_title( '<h5 class="card-title"><a href="' . esc_url( get_permalink() ) . '">', '</a></h5>' ); ?>

        <div class="card-text">
            <?php the_excerpt(); ?>
        </div>

        <a href="<?php the_permalink(); ?>" class="btn btn-link text-primary p-0">
            <?php esc_html_e( 'Read More', 'paws-and-care' ); ?> <i class="fa-solid fa-arrow-right ms-1"></i>
        </a>
    </div>
</article>

