<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package WowPress
 */

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<div class="post-wrapper" style="--author-class:var(--color-deathknight)">
		<div class="post-title"><h1><?php the_title()?></h1></div>
		<div class="post-content"><?php the_content() ?></div>
		<div class="post-day"><?=get_the_date('d')?></div>
		<div class="post-month"><?=get_the_date('F')?></div>
		<?php
		$category = get_the_category();
		$category = array_pop($category);
		$color = get_term_meta( $category->term_id, 'color', true );
		?>
		<div class="post-category ribbon" style="--color-ribbon:#<?= ctype_xdigit($color)?$color:'fff'?>"><span><?=$category->name?></span></div>
		<div class="post-avatar"><img src="<?=get_avatar_url( get_the_author_meta( 'ID' ));?>"></div>
		<div class="post-author">
		<?php if(current_user_can('edit_post',$post->ID)): ?>
		<a href="<?=get_edit_post_link($post->ID)?>">
		<?=get_the_author()?>
		</a>
		<?php else: ?>
		<?=get_the_author()?>
		<?php endif; ?>
	</div>
</article><!-- #post-${ID} -->
