{{ $news->title }} {{ $news->taxonomy_label }} @if($news->published_at) ยท {{ $news->published_at->format('F j, Y') }} @endif @php $renderableBlocks = $news->renderable_content_blocks; $hasRenderableContent = false; @endphp @foreach($renderableBlocks as $block) @php $type = $block['type'] ?? null; @endphp @if($type === 'image') @php $imagePath = trim($block['image_path'] ?? ''); @endphp @if($imagePath !== '') @php $hasRenderableContent = true; @endphp @if(! empty($block['caption'])) {{ $block['caption'] }} @endif @endif @elseif($type === 'text') @php $rawBody = $block['body'] ?? ''; $sanitizedBody = $rawBody !== '' ? strip_tags($rawBody, '') : ''; $formattedBody = $sanitizedBody !== '' ? nl2br($sanitizedBody) : ''; @endphp @if($formattedBody !== '') @php $hasRenderableContent = true; @endphp {!! $formattedBody !!} @endif @elseif($type === 'youtube') @php $rawUrl = trim($block['embed_url'] ?? ''); $youtubeId = null; if ($rawUrl !== '') { $parsed = parse_url($rawUrl); $query = []; if (isset($parsed['query'])) { parse_str($parsed['query'], $query); } $path = $parsed['path'] ?? ''; if (! empty($query['v'])) { $youtubeId = $query['v']; } elseif (! empty($path)) { $segments = explode('/', trim($path, '/')); if (str_contains($parsed['host'] ?? '', 'youtu.be') && isset($segments[0])) { $youtubeId = $segments[0]; } elseif (($segments[0] ?? '') === 'embed' && isset($segments[1])) { $youtubeId = $segments[1]; } } } @endphp @if($youtubeId) @php $hasRenderableContent = true; @endphp @endif @elseif(in_array($type, ['facebook', 'tiktok', 'twitter'])) @php $embedUrl = trim($block['embed_url'] ?? ''); @endphp @if($embedUrl !== '') @php $hasRenderableContent = true; @endphp @if($type === 'facebook') @elseif($type === 'tiktok') @php $videoId = null; if (preg_match('#/video/(\d+)#', $embedUrl, $matches)) { $videoId = $matches[1]; } @endphp @if($videoId) @else @endif @elseif($type === 'twitter') @endif @endif @endif @endforeach @if(! $hasRenderableContent) {{ __('This article does not have any content yet.') }} @endif