@php
$columns = (int) ($options['columns'] ?? 3);
$color = $options['color'] ?? 'transparent';
$padding = $options['padding'] ?? 'lg';
$colSize = (int) (12 / max(1, $columns));
$locale = app()->getLocale();
@endphp
<section class="page-block-latest-announcements py-{{ $padding }} @if($color !== 'transparent') {{ pb_bg_class($color) }} @endif">
    <div class="container">
        @if(! empty($data['title']))<h2 class="text-center mb-5">{{ $data['title'] }}</h2>@endif
        <div class="row g-4">
            @foreach($announcements as $a)
                @php
                    $slug = $a->getTranslation('slug', $locale) ?: $a->slug;
                    $title = $a->getTranslation('title', $locale) ?: $a->title;
                @endphp
                <div class="col-md-{{ $colSize }}">
                    <article class="card h-100">
                        <div class="card-body">
                            @if(! empty($data['show_date']))
                                <small class="text-muted">{{ $a->published_at ? format_client_date($a->published_at) : '' }}</small>
                            @endif
                            <h4><a href="{{ lroute('announcements.show', $slug) }}" class="text-decoration-none">{{ $title }}</a></h4>
                            @if(! empty($data['show_excerpt']) && ! empty($a->excerpt))
                                <p class="text-muted">{{ Str::limit($a->getTranslation('excerpt', $locale) ?: $a->excerpt, 150) }}</p>
                            @endif
                        </div>
                    </article>
                </div>
            @endforeach
        </div>
    </div>
</section>
