Update (list): Fix crash on list output
This commit is contained in:
@@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
if (! function_exists('str_first_sentence')) {
|
||||||
|
function str_first_sentence($str) {
|
||||||
|
// Split the string at ., !, or ?
|
||||||
|
$sentences = preg_split('/(\.|!|\?)(\s|$)/', $str, 2);
|
||||||
|
|
||||||
|
// Return the first part of the array if available
|
||||||
|
if (isset($sentences[0])) {
|
||||||
|
return trim($sentences[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no sentence ending found, return the whole string
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (! function_exists('is_empty')) {
|
if (! function_exists('is_empty')) {
|
||||||
/**
|
/**
|
||||||
* A better function to check if a value is empty or null. Strings, arrays, and Objects are supported.
|
* A better function to check if a value is empty or null. Strings, arrays, and Objects are supported.
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
'level' => [1, 2, 3, 4, 5, 6],
|
'level' => [1, 2, 3, 4, 5, 6],
|
||||||
],
|
],
|
||||||
'list' => [
|
'list' => [
|
||||||
'type' => [
|
'style' => [
|
||||||
0 => 'ordered',
|
'type' => 'string',
|
||||||
1 => 'unordered',
|
'allowedValues' => ['ordered', 'unordered']
|
||||||
],
|
],
|
||||||
'items' => [
|
'items' => [
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class="text-decoration-none">{{ $post->title }}</a>
|
|||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<small class="text-secondary">{{ $post->excerpt }}</small>
|
<small class="text-secondary">{{ str_first_sentence($post->excerpt) }}</small>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
$tag = "h{$level}";
|
$tag = "h{$level}";
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<{{ $tag }}>{{ $data['text'] ?? '' }}</{{ $tag }}>
|
<{{ $tag }} class="fw-bold">{!! $data['text'] ?? '' !!}</{{ $tag }}>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<figure class="image {{ $classes }}">
|
<figure class="image {{ $classes }}">
|
||||||
<img src="{{ $data['file']['url'] }}" alt="{{ $data['caption'] ?: '' }}">
|
<img class="img-fluid rounded-2 shadow-sm mb-2" src="{{ $data['file']['url'] }}" alt="{{ $data['caption'] ?: '' }}">
|
||||||
@if (!empty($data['caption']))
|
@if (!empty($data['caption']))
|
||||||
<footer class="image-caption">
|
<footer class="image-caption">
|
||||||
{{ $data['caption'] }}
|
{{ $data['caption'] }}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@php
|
@php
|
||||||
$tag = 'ul';
|
$tag = 'ul';
|
||||||
if ('ordered' === $data['type']) {
|
if ('ordered' === $data['style']) {
|
||||||
$tag = 'ol';
|
$tag = 'ol';
|
||||||
}
|
}
|
||||||
@endphp
|
@endphp
|
||||||
|
|||||||
Reference in New Issue
Block a user