@foreach($homepageBlocks as $block)
@php
$isFullWidth = !empty($block['data']['is_full_width']);
$containerClass = $isFullWidth ? 'w-full px-6 mb-24' : 'max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 mb-24';
@endphp
@switch($block['type'])
@case('hero')
@if(!empty($block['data']['bg_image']))
@if(!empty($block['data']['subtitle']))
{{ $block['data']['subtitle'] }}
@endif
@if(!empty($block['data']['cta_text']) && !empty($block['data']['cta_url']))
{{ $block['data']['cta_text'] }}
@endif
@else
@if(!empty($block['data']['subtitle']))
{{ $block['data']['subtitle'] }}
@endif
@if(!empty($block['data']['cta_text']) && !empty($block['data']['cta_url']))
@endif
@endif
@break
@case('featured_stories')
@php
$limit = $block['data']['limit'] ?? 6;
$displayStories = $featuredStories->take($limit);
$isCarousel = !empty($block['data']['is_carousel']);
@endphp
@if(!empty($block['data']['description']))
{{ $block['data']['description'] }}
@endif
@if($displayStories->isEmpty())
No featured stories at the moment. Browse our projects to see more impact stories.
@else
@if($isCarousel)
@foreach($displayStories as $story)
@php
$firstTextBlock = collect($story->content)->firstWhere('type', 'text');
$summary = $firstTextBlock ? Str::limit(strip_tags($firstTextBlock['data']['content']), 150) : 'Click to read this success story...';
@endphp
@if($story->image)
 }})
@else
@endif
@if($story->project)
{{ $story->project->short_name ?? $story->project->name }}
@endif
Published {{ $story->published_date ? $story->published_date->format('M d, Y') : $story->created_at->format('M d, Y') }}
{{ $story->title }}
{{ $summary }}
@endforeach
@else
@foreach($displayStories as $story)
@php
$firstTextBlock = collect($story->content)->firstWhere('type', 'text');
$summary = $firstTextBlock ? Str::limit(strip_tags($firstTextBlock['data']['content']), 150) : 'Click to read this success story...';
@endphp
@if($story->image)
 }})
@else
@endif
@if($story->project)
{{ $story->project->short_name ?? $story->project->name }}
@endif
Published {{ $story->published_date ? $story->published_date->format('M d, Y') : $story->created_at->format('M d, Y') }}
{{ $story->title }}
{{ $summary }}
@endforeach
@endif
@endif
@break
@case('projects_grid')
@php
$isCarousel = !empty($block['data']['is_carousel']);
@endphp
{{ $block['data']['title'] ?? 'Our Projects' }}
@if(!empty($block['data']['description']))
{{ $block['data']['description'] }}
@endif
@if($isCarousel)
@foreach($projects as $project)
@endforeach
@else
@endif
@break
@case('thematic_areas_grid')
{{ $block['data']['title'] ?? 'Thematic Areas' }}
@if(!empty($block['data']['description']))
{{ $block['data']['description'] }}
@endif
@break
@case('newsletters')
@php
$limit = $block['data']['limit'] ?? 6;
$displayNewsletters = $newsletters->take($limit);
$isCarousel = !empty($block['data']['is_carousel']);
@endphp
@if(!empty($block['data']['description']))
{{ $block['data']['description'] }}
@endif
@if($displayNewsletters->isEmpty())
No newsletters available at the moment.
@else
@if($isCarousel)
@foreach($displayNewsletters as $newsletter)
@php
$firstTextBlock = collect($newsletter->content)->firstWhere('type', 'text');
$summary = $firstTextBlock ? Str::limit(strip_tags($firstTextBlock['data']['content']), 150) : 'Explore the details of this newsletter issue...';
@endphp
@if($newsletter->cover_image)
 }})
@else
@endif
@if($newsletter->category)
{{ $newsletter->category->name }}
@endif
Published {{ $newsletter->published_date ? $newsletter->published_date->format('M d, Y') : $newsletter->created_at->format('M d, Y') }}
{{ $newsletter->title }}
{{ $summary }}
@endforeach
@else
@foreach($displayNewsletters as $newsletter)
@php
$firstTextBlock = collect($newsletter->content)->firstWhere('type', 'text');
$summary = $firstTextBlock ? Str::limit(strip_tags($firstTextBlock['data']['content']), 150) : 'Explore the details of this newsletter issue...';
@endphp
@if($newsletter->cover_image)
 }})
@else
@endif
@if($newsletter->category)
{{ $newsletter->category->name }}
@endif
Published {{ $newsletter->published_date ? $newsletter->published_date->format('M d, Y') : $newsletter->created_at->format('M d, Y') }}
{{ $newsletter->title }}
{{ $summary }}
@endforeach
@endif
@endif
@break
@case('parallax')
@php
$isParallaxFullWidth = filter_var($block['data']['is_full_width'] ?? true, FILTER_VALIDATE_BOOLEAN);
$titleColor = $block['data']['title_color'] ?? '#ffffff';
$subtitleColor = $block['data']['subtitle_color'] ?? '#ffffff';
$height = $block['data']['height'] ?? 'medium';
$heightStyle = $height == 'small' ? '300px' : ($height == 'large' ? '700px' : '500px');
@endphp
@if(!empty($block['data']['title']))
{{ $block['data']['title'] }}
@endif
@if(!empty($block['data']['subtitle']))
{{ $block['data']['subtitle'] }}
@endif
@break
@case('custom_html')
@if(!empty($block['data']['title']))
{{ $block['data']['title'] }}
@endif
{!! $block['data']['content'] !!}
@break
@endswitch
@endforeach
@endsection