@extends('user.template')

@section('title', 'Berita')

@section('content')

    <div class="page-title">
        <div class="container d-lg-flex justify-content-between align-items-center">
            <h1 class="mb-2 mb-lg-0">Berita</h1>

            <nav class="breadcrumbs">
                <ol>
                    <li><a href="{{ route('user.index') }}">Beranda</a></li>
                    <li class="current">Berita</li>
                </ol>
            </nav>
        </div>
    </div>


    <section id="blog-posts" class="blog-posts section">
        <div class="container">
            <div class="row gy-4">

                @forelse ($berita as $item)
                    <div class="col-lg-4">
                        <article>

                            <div class="post-img">

                                @if ($item->gambar_informasi)
                                    <img src="{{ asset('storage/' . $item->gambar_informasi) }}"
                                        alt="{{ $item->judul_informasi }}" class="img-fluid">
                                @else
                                    <img src="{{ asset('assets/img/blog/default.jpg') }}" alt="default" class="img-fluid">
                                @endif

                            </div>


                            <p class="post-category">
                                <time datetime="{{ $item->tanggal_informasi }}">
                                    {{ \Carbon\Carbon::parse($item->tanggal_informasi)->translatedFormat('d F Y') }}
                                </time>
                            </p>


                            <h2 class="title">
                                <a href="{{ route('user.detail-berita', $item->id_informasi) }}">
                                    {{ Str::limit($item->judul_informasi, 40) }}
                                </a>
                            </h2>


                            <div class="d-flex align-items-start">
                                <div class="post-meta ms-2">

                                    <p class="post-excerpt">
                                        {{ Str::limit(strip_tags($item->isi_informasi), 120, '...') }}
                                    </p>

                                </div>
                            </div>

                        </article>
                    </div>

                @empty

                    <div class="text-center col-12">
                        <p>Belum ada berita tersedia.</p>
                    </div>
                @endforelse

            </div>


            <div class="mt-4 d-flex justify-content-center">
                {{ $berita->links() }}
            </div>


        </div>
    </section>

@endsection
