@if ($socials)
@foreach ($socials as $value)
@php
// Determine the display text and URL based on social network type
$isBlueSky = $value->id == 3; // Assuming Blue Sky has ID 3
$isFullUrl = str_starts_with($value->pivot->user_on_social, 'https://');
if ($isBlueSky) {
// For Blue Sky, the handle already includes the domain (user.bsky.social)
$displayText = '@' . $value->pivot->user_on_social;
$url = "https://bsky.app/profile/{$value->pivot->user_on_social}";
} elseif ($isFullUrl) {
// For other services that store full URLs (like WhatsApp links)
$displayText = Str::of($value->pivot->user_on_social)->limit(44);
$url = $value->pivot->user_on_social;
} elseif ($value->pivot->server_of_social) {
// For Mastodon and similar services with servers
$displayText =
'@' . $value->pivot->user_on_social . '@' . $value->pivot->server_of_social;
$url =
str_replace('#', $value->pivot->server_of_social, $value->url_structure) .
$value->pivot->user_on_social;
} else {
// For standard services (Facebook, Twitter, etc.)
$displayText = '@' . $value->pivot->user_on_social;
$url = $value->url_structure . $value->pivot->user_on_social;
}
@endphp