<?php

/**
 * Template part for displaying posts
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Viralike
 * @subpackage template-parts
 */

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(['post-card']); ?>>

	<?php if (has_post_thumbnail()) : ?>
		<a class="post-card--image" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" aria-hidden="true" tabindex="-1">
			<?php the_post_thumbnail('medium_large'); ?>
		</a><!-- .post-card--image -->
	<?php endif; ?>

	<div class="post-card--body">

		<?php echo '<time class="post-card--body__time"><i class="icon-calendar-empty"></i>' . esc_html(get_the_date()) . '</time>'; ?>
		<!-- .post-card--body__time -->

		<header class="entry-header post-card--body__header">
			<?php the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>'); ?>
		</header><!-- .post-card--body__header -->

		<div class="entry-meta post-card--body__meta">
			<?php
			if (has_category()) {
				the_category(' ');
			} ?>
		</div><!-- .post-card--body__meta -->

		<div class="entry-content post-card--body__content">
			<?php
			if (has_excerpt()) {
				the_excerpt();
			} elseif (strpos($post->post_content, '<!--more-->')) {
				the_content(esc_html('Read more', 'viralike'));
			} else {
				the_excerpt();
			} ?>
		</div><!-- .post-card--body__content -->

		<div class="entry-content post-card--body__author">
			<?php the_author_posts_link(''); ?>
		</div><!-- .post-card--body__author -->

	</div><!-- .post-card--body -->

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