@extends('layouts.app') @section('title', $story->title . ' - UN-Habitat Nepal') @section('content')
{{-- Header & Featured Image --}}

{{ $story->title }}

@if($story->image)
{{ $story->image_alt ?: $story->title }}
@endif
Published {{ $story->published_date ? $story->published_date->format('M d, Y') : $story->created_at->format('M d, Y') }} @if($story->is_featured) Featured Story @endif
{{-- Content Blocks --}} @foreach($story->content as $block) @if($block['type'] === 'parallax' && filter_var($block['data']['is_full_width'] ?? true, FILTER_VALIDATE_BOOLEAN)) @php $titleColor = $block['data']['title_color'] ?? '#ffffff'; $subtitleColor = $block['data']['subtitle_color'] ?? '#ffffff'; @endphp @else
@switch($block['type']) @case('text')
{!! $block['data']['content'] !!}
@break @case('image')
{{ !empty($block['data']['image_alt']) ? $block['data']['image_alt'] : ($block['data']['caption'] ?? '') }} @if(!empty($block['data']['caption']))
{{ $block['data']['caption'] }}
@endif
@break @case('quote')

"{{ $block['data']['quote'] }}"

@if(!empty($block['data']['author'])) — {{ $block['data']['author'] }} @endif
@break @case('parallax') @php $titleColor = $block['data']['title_color'] ?? '#ffffff'; $subtitleColor = $block['data']['subtitle_color'] ?? '#ffffff'; @endphp @break @case('slideshow')
@foreach($block['data']['slides'] as $slide) @php $fontColor = $slide['font_color'] ?? '#ffffff'; @endphp
{{ !empty($slide['image_alt']) ? $slide['image_alt'] : ($slide['caption'] ?? '') }} @if(!empty($slide['caption']) || !empty($slide['subcaption']))
@if(!empty($slide['caption']))
{{ $slide['caption'] }}
@endif @if(!empty($slide['subcaption']))
{{ $slide['subcaption'] }}
@endif
@endif
@endforeach
@break @case('video') @php $videoSource = $block['data']['source'] ?? 'youtube'; $caption = $block['data']['caption'] ?? null; @endphp
@if($videoSource === 'youtube' && !empty($block['data']['youtube_url'])) @php $youtubeUrl = $block['data']['youtube_url']; $videoId = null; if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/\s]{11})%i', $youtubeUrl, $match)) { $videoId = $match[1]; } @endphp @if($videoId)
@else
Invalid YouTube URL provided.
@endif @elseif($videoSource === 'file' && !empty($block['data']['video_file']))
@endif @if(!empty($caption))

{{ $caption }}

@endif
@break @endswitch
@endif @endforeach @if($relatedStories->isNotEmpty())

{{ $story->project ? 'More from ' . $story->project->name : 'More Stories' }}

@foreach($relatedStories as $related)
@if($related->image) {{ $related->image_alt ?: $related->title }} @endif

{{ $related->title }}

@endforeach
@endif
@endsection