@php function kategoriWarna($nama) { $colors = [ 'bg-red-500', 'bg-green-500', 'bg-blue-500', 'bg-yellow-500', 'bg-purple-500', 'bg-pink-500', 'bg-indigo-500', 'bg-emerald-600', 'bg-cyan-600', 'bg-orange-500', 'bg-amber-600', 'bg-teal-500', ]; $index = crc32(strtolower($nama)) % count($colors); return $colors[$index]; } @endphp @extends('layouts.app') @section('title', $news->title) @section('meta-og') {{-- Optional: Twitter card --}} @endsection @section('head') {{-- Font Awesome untuk ikon --}} @endsection @section('content')
{{-- Pesan Flash (Sukses/Error) --}} @if(session('success')) @endif @if(session('error')) @endif {{-- 📰 Konten Berita Utama --}}
{{-- Media Berita (Gambar/Video) --}} @php $ext = pathinfo($news->image ?? '', PATHINFO_EXTENSION); // Handle if image is null $isVideo = in_array(strtolower($ext), ['mp4', 'webm', 'ogg']); $hasMedia = $news->image && file_exists(public_path('storage/' . $news->image)); @endphp
@if ($hasMedia) @if ($isVideo) @else {{ $news->title }} @endif @else
Tidak ada media tersedia
@endif
{{-- Isi Konten --}}

{{ $news->title }}

Kategori: {{ $news->category }} Dipublikasikan pada {{ \Carbon\Carbon::parse($news->publish_date)->translatedFormat('d F Y') }} Oleh: {{ $news->user->name ?? 'Tidak diketahui' }}
{!! html_entity_decode($news->content) !!}
{{-- Tombol Bagikan --}}

Bagikan Berita Ini

@php $shareUrl = urlencode(route('frontend.berita.show', $news->slug)); $shareTitle = urlencode($news->title); @endphp WhatsApp Facebook Twitter Email
{{-- Footer Berita --}}
{{ number_format($news->view_count) }} views {{ number_format($news->like_count) }} likes
{{-- Tombol Like --}}
@csrf
{{-- Kembali ke Beranda --}} Kembali ke Beranda
{{-- 💬 Komentar --}}

Komentar ({{ $comments->total() }})

@auth
@csrf
@else

Silakan login untuk memberikan komentar.

@endauth
@forelse ($comments as $comment) {{-- Asumsi komponen comment sudah dioptimalkan --}} @include('components.comment', ['comment' => $comment]) @empty

Belum ada komentar.

@endforelse
{{ $comments->links() }}
{{-- 🗞️ Berita Terkait --}} @if($relatedNews->count())

Berita Terkait

@endif
@endsection