@extends('layouts.app') @section('title', ($currentCategory?->name ? $currentCategory->name.' Articles' : 'All Articles').' | Homeland News') @section('meta_description', $currentCategory?->name ? ('Latest '.$currentCategory->name.' articles from Homeland News.') : 'Browse the latest articles from Homeland News across politics, business, tech, sports and more.') @section('canonical', url()->full()) @section('content')

{{ $currentCategory?->name ? $currentCategory->name : 'All Articles' }}

@if($currentCategory) Clear filter @endif
@if($articles->count() === 0)
No articles found.
@else @php $collection = ($articles instanceof \Illuminate\Pagination\LengthAwarePaginator || $articles instanceof \Illuminate\Pagination\Paginator) ? $articles->getCollection() : collect($articles); @endphp @if($currentCategory)
@foreach($collection as $article) @php $img = $article->image_url ? (preg_match('/^https?:\/\//i',$article->image_url) ? $article->image_url : asset(ltrim($article->image_url,'/'))) : 'https://via.placeholder.com/640x360'; $author = optional($article->author)->name; @endphp @endforeach
{{ $articles->links() }}
@else @php $topThree = $collection->take(3); $rest = $collection->slice(3); @endphp @if($topThree->count() > 0)
@include('partials.ad-slot', ['placement' => 'index-top'])
@foreach($topThree as $article) @php $img = $article->image_url ? (preg_match('/^https?:\/\//i',$article->image_url) ? $article->image_url : asset(ltrim($article->image_url,'/'))) : 'https://via.placeholder.com/640x360'; $author = optional($article->author)->name; @endphp @endforeach
@endif
@foreach($rest as $article) @php $img = $article->image_url ? (preg_match('/^https?:\/\//i',$article->image_url) ? $article->image_url : asset(ltrim($article->image_url,'/'))) : 'https://via.placeholder.com/640x360'; $author = optional($article->author)->name; @endphp @endforeach
{{ $articles->links() }}
@endif
@endif @endsection