<?php
$relatedPostId = $attributes['relatedPostId'] ?? null;

$relatedPost = get_post($relatedPostId) ?? null;
$relatedPostUrl = get_permalink($relatedPostId) ?? null;

$postIcon =  get_field("step_icon", $relatedPostId) ?? null;
$excerpt = get_the_excerpt($relatedPostId) ?? null;

?>
<a class="homegrade-blocks-page-card" href="<?php echo $relatedPostUrl ?>">
	<img class="homegrade-blocks-page-card__icon" src="<?php echo $postIcon['url'] ?>" alt="">
	<h3 class="homegrade-blocks-page-card__title"><?php echo $relatedPost->post_title; ?></h3>
	<p class="homegrade-blocks-page-card__excerpt"><?php echo $excerpt ?></p>
	<div class="homegrade-blocks-page-card__cta" href="<?php echo $relatedPostUrl ?>" target="_self" rel="noopener">
		<p>En savoir plus</p>
		<div class="cta_arrow_button">
			<img src='<?php echo get_template_directory_uri() ?>/resources/img/graphic-assets/arrow-right-circle.svg' alt=''>
		</div>
	</div>
</a>