@extends('layouts.web') @section('content')

{{ $news->title }}

{{ $news->category->name ?? 'Berita' }} {{ $news->published_at ? $news->published_at->format('d F Y') : 'Draft' }}

@php $heroExcerpt = \Illuminate\Support\Str::limit(strip_tags($news->content ?? ''), 180); @endphp @if(!empty($heroExcerpt))

{{ $heroExcerpt }}

@endif
Berita Terkini
@if($news->image) {{ $news->title }} @else Default Image @endif
{{ $news->category->name ?? 'Uncategorized' }} {{ $news->published_at ? $news->published_at->format('d F Y H:i') : 'Draft' }} {{ $news->author->name ?? 'Unknown' }} {{ $news->views_count ?? 0 }} views

{{ $news->title }}

@php $html = $news->content ?? ''; $normalize = function($url) { $u = trim($url); if (preg_match('#(youtube\.com/watch\?v=|youtu\.be/)([A-Za-z0-9_-]{6,})#', $u, $m)) { return 'https://www.youtube.com/embed/'.$m[2]; } if (preg_match('#youtube\.com/shorts/([A-Za-z0-9_-]{6,})#', $u, $m)) { return 'https://www.youtube.com/embed/'.$m[1]; } if (preg_match('#vimeo\.com/(\d+)#', $u, $m)) { return 'https://player.vimeo.com/video/'.$m[1]; } return null; }; $convert = function($input) use ($normalize) { $out = preg_replace_callback('/]+href="([^"]+)"[^>]*>[\s\S]*?<\/a>/i', function($m) use ($normalize) { $e = $normalize($m[1]); return $e ? '' : $m[0]; }, $input); $pattern = '~((?:https?://)?(?:www\.|m\.)?(?:youtube\.com/watch\?v=[A-Za-z0-9_-]{6,}|youtu\.be/[A-Za-z0-9_-]{6,}|youtube\.com/shorts/[A-Za-z0-9_-]{6,}|vimeo\.com/\d+))~i'; $out = preg_replace_callback($pattern, function($m) use ($normalize) { $e = $normalize($m[1]); return $e ? '' : $m[1]; }, $out); // Remove code/pre wrappers around pure video URLs $out = preg_replace_callback('/]*>([\s\S]*?)<\/pre>/i', function($m) use ($normalize) { $text = strip_tags($m[1]); $text = trim(html_entity_decode($text)); $e = $normalize($text); return $e ? '' : $m[0]; }, $out); $out = preg_replace_callback('/]*>([\s\S]*?)<\/code>/i', function($m) use ($normalize) { $text = strip_tags($m[1]); $text = trim(html_entity_decode($text)); $e = $normalize($text); return $e ? '' : $m[0]; }, $out); return $out; }; $render = \Mews\Purifier\Facades\Purifier::clean($convert($html), 'youtube'); @endphp {!! $render !!}
@if($news->featured)
Berita Unggulan
@endif
Rating & Komentar
{{ $totalRatings }} rating
{{ number_format($averageRating, 1) }}
Berdasarkan {{ $totalRatings }} rating
@for($i=1;$i<=5;$i++) @endfor
@for($i=5; $i>=1; $i--) @php $count = $ratingCounts[$i] ?? 0; $pct = $totalRatings > 0 ? round(($count / $totalRatings) * 100) : 0; @endphp
{{ $i }}
{{ $count }}
@endfor

@auth
@csrf
Berikan Rating
@for($i=1;$i<=5;$i++) @endfor
Pilih rating untuk berita ini
Tambah Komentar
@else
Berikan Rating
@for($i=1;$i<=5;$i++) @endfor
Tambah Komentar
@endauth
Semua Komentar
@forelse($news->comments as $comment) @php $isRatingOnly = $comment->rating && empty(trim($comment->body ?? '')); @endphp @if($isRatingOnly) @continue @endif @include('partials.news_comment_item', ['comment' => $comment, 'news' => $news]) @empty
Belum ada komentar.
@endforelse
@endsection @push('styles') {{-- Semua CSS sudah dipindahkan ke central.css --}} @endpush @push('scripts') @endpush