@extends('frontend.theme1.index', ['title' => ($newsItem->title ?? 'Media') . ' - Fitness Plus Indonesia', 'count' => $count ?? 0]) @section('content') @php $detailPublishedAt = $newsItem->published_at ?? $newsItem->created_at; $detailImagePath = trim((string) ($newsItem->image ?? '')); $detailImageUrl = $detailImagePath !== '' ? (\Illuminate\Support\Str::startsWith($detailImagePath, ['http://', 'https://', '//']) ? $detailImagePath : asset(ltrim($detailImagePath, '/'))) : ''; $creatorName = trim((string) ($newsItem->author ?? '')); $creatorName = $creatorName !== '' ? $creatorName : 'Fitness Plus Indonesia'; $creatorImagePath = trim((string) (data_get($newsItem, 'author_image') ?: data_get($newsItem, 'creator_image') ?: '')); $creatorImageUrl = $creatorImagePath !== '' ? (\Illuminate\Support\Str::startsWith($creatorImagePath, ['http://', 'https://', '//']) ? $creatorImagePath : asset(ltrim($creatorImagePath, '/'))) : ''; $creatorInitials = collect(array_filter(preg_split('/\s+/', $creatorName))) ->take(2) ->map(fn ($segment) => \Illuminate\Support\Str::upper(\Illuminate\Support\Str::substr($segment, 0, 1))) ->implode(''); $creatorInitials = $creatorInitials !== '' ? $creatorInitials : 'FP'; $shareUrl = url()->current(); $shareTitle = trim((string) ($newsItem->title ?? 'Media Fitness Plus Indonesia')); $shareSummary = trim((string) preg_replace('/\s+/', ' ', strip_tags((string) ($newsItem->content ?? '')))); $shareText = trim($shareTitle . ($shareSummary !== '' ? ' - ' . \Illuminate\Support\Str::limit($shareSummary, 120, '...') : '')); $whatsAppShareUrl = 'https://wa.me/?text=' . rawurlencode($shareText . ' ' . $shareUrl); $tiktokShareUrl = 'https://www.tiktok.com/share?url=' . rawurlencode($shareUrl) . '&text=' . rawurlencode($shareTitle); $emailShareUrl = 'mailto:?subject=' . rawurlencode($shareTitle) . '&body=' . rawurlencode($shareText . "\n\n" . $shareUrl); $facebookShareUrl = 'https://www.facebook.com/sharer/sharer.php?u=' . rawurlencode($shareUrl); @endphp