<?php

// get post
/**
 * @var WP_Post
 */
$post = $args["post"] ?? false;
if (!$post) {
  return;
}

// get categories
$categories = get_the_category($post instanceof WP_Post ? $post->ID : $post);
?>
<div class="post-card" onclick="window.location.href='<?php the_permalink($post); ?>'">
  <?php $url = get_the_post_thumbnail_url($post, "s-6"); ?>
  <?php if ($url): ?>
  <img src="<?= $url ?>" alt="<?= get_the_title($post) ?>">
  <?php else: ?>
  <img class="default" src="<?= get_theme_file_uri("assets/svg/logo.svg") ?>" alt="logo">
  <?php endif; ?>
  <a href="<?php the_permalink($post); ?>" class="post-card-content">
    <div class="content">
      <div class="info">
        <?php foreach ($categories as $category): ?>
        <span class="category">
          <?= $category->name ?>
        </span>
        <?php endforeach; ?>
        <time class="date" datetime="<?= get_the_time("Y-m-d H:i:s", $post) ?>">
          <?= get_the_time("d.m.Y", $post) ?>
        </time>
      </div>
      <h4 class="title">
        <?= get_the_title($post) ?>
      </h4>
      <p class="excerpt">
        <?= get_the_excerpt($post) ?>
      </p>
    </div>
  </a>
</div>