<?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://twitter.com/intent/tweet?text=' . $postTitle  . '&url=' . get_the_permalink(get_the_id());
		$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">

	<ul class="post-infos-capsule__share">
		<?php foreach ($shareUrls as $key => $shareUrl) : ?>
			<li class="share-button share-button--<?php echo  $key ?>">
				<a href='<?php echo  $shareUrl ?>' class="share-link" target="_blank" title="<?php echo __("Partager ce contenu sur ", "homegrade-theme__texte-fonctionnel") . $key ?>">
				</a>
			</li>
		<?php endforeach; ?>
	</ul>
	<?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>