<?php
$postID = $args['postID'];
$published = $args['published'] ?? null;
$modified = $args['modified'] ?? null;

if (!function_exists('build_share_urls')) {
	function build_share_urls($postID)
	{
		$postUrl = get_permalink($postID);
		$postTitle = get_the_title($postID);
		$facebookUrl = 'https://www.facebook.com/sharer.php?u=' . $postUrl;
		$twitterUrl = 'https://www.facebook.com/sharer.php?u=' . $postUrl;
		$linkedInUrl = 'https://www.linkedin.com/feed/?shareActive=true&text=' . $postTitle . ' ' . $postUrl;

		return array(
			'facebook' => $facebookUrl,
			'twitter-x' => $twitterUrl,
			'linkedin' => $linkedInUrl
		);
	}
}

$shareUrls = build_share_urls($postID);


?>

<div class="post-infos-capsule">
	<div class="post-infos-capsule__share">
		<?php
		__('Partager sur', 'homegrade-theme__texte-fonctionnel')
		?>
		<?php foreach ($shareUrls as $key => $shareUrl) : ?>
			<a class="share-button share-button--<?php echo  $key ?>" href='<?php echo  $shareUrl ?>' target="_blank" title="<?php echo __("Partager ce contenu sur", "homegrade-theme__texte-fonctionnel") . $key ?>">
				<?php if ($key) : ?>
					<!-- <img src="<?php echo get_template_directory_uri() . '/resources/img/graphic-assets/icone-social-' . $key . '.svg' ?>" /> -->
				<?php endif; ?>
			</a>
		<?php endforeach; ?>
	</div>
	<?php if ($published) : ?>
		<div class="post-infos-capsule__publication-date">
			<time><?php echo __("Publié le ", "homegrade-theme__texte-fonctionnel") . $published ?></time>
		</div>
	<?php endif; ?>
	<?php if ($modified) : ?>
		<div class="post-infos-capsule__modification-date">
			<time><?php echo __("Mis à jour le ", "homegrade-theme__texte-fonctionnel") . $modified ?></time>
		</div>
	<?php endif; ?>

</div>