@props(['blocks'])
@if ($blocks)
@if (is_array($blocks))
@foreach ($blocks as $block)
@switch($block['type'])
@case('rich_text')
@case('html')
{!! $block['data']['content'] !!}
@break
@case('markdown')
{!! \Illuminate\Support\Str::markdown($block['data']['content']) !!}
@break
@case('image')
@break
@case('pdf_embed')
@break
@case('youtube_video')
@php
preg_match(
'/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/',
$block['data']['url'],
$matches,
);
$blockVideoId = $matches[1] ?? null;
@endphp
@if ($blockVideoId)
@endif
@break
@case('hero')
@if (!empty($block['data']['title']))
{{ $block['data']['title'] }}
@endif
@if (!empty($block['data']['subtitle']))
{{ $block['data']['subtitle'] }}
@endif
@break
@case('alert')
{!! $block['data']['content'] !!}
@break
@case('button_snippet')
@break
@case('card_snippet')
@if (!empty($block['data']['image']))
![{{ $block['data']['title'] ?? '' }}]({{ \Illuminate\Support\Facades\Storage::url($block['data']['image']) }})
@endif
@if (!empty($block['data']['title']))
{{ $block['data']['title'] }}
@endif
{!! $block['data']['content'] !!}
@if (!empty($block['data']['button_label']) && !empty($block['data']['button_url']))
{{ $block['data']['button_label'] }}
@endif
@break
@default
Unknown block type: {{ $block['type'] }}
@endswitch
@endforeach
@elseif(is_string($blocks))