@php if (!function_exists('calculateReadingTime')) { function calculateReadingTime($body) { if (!$body) { return 2; } $text = strip_tags($body); $words = str_word_count($text); $minutes = ceil($words / 200); return max(1, $minutes); } } @endphp
@if ($latestPosts && $latestPosts->count() > 0) @foreach ($latestPosts as $index => $latestPost) @php $latestImage = $latestPost->topImage ?? $latestPost->featuredImage; $latestImageUrl = $latestImage?->file_url ?? '/assets/theme/v6/images/profile_1-120x120.jpeg'; $latestUrl = url("/{$latestPost->slug}"); $latestReadingTime = calculateReadingTime($latestPost->body); $latestAuthorName = $latestPost->authorUser?->name ?? ($latestPost->author_name ?? ($latestPost->author ?? 'Redação')); $latestAuthorAvatar = $latestPost->authorUser?->avatar_url ?? '/assets/theme/v6/images/profile_1-120x120.jpeg'; @endphp @if ($index === 0) {{-- Primeiro post como destaque --}}
@if ($latestImage)
{{ $latestPost->title }}
@endif
@if ($latestPost->section) {{ $latestPost->section->name }} @endif

{{ $latestPost->title }}

{{-- --}}
@else {{-- Posts seguintes como lista --}}
@if ($latestImage)
{{ $latestPost->title }}
@endif
@if ($latestPost->section) {{ $latestPost->section->name }} @endif

{{ $latestPost->title }}

{{-- --}}
@endif @endforeach @endif