Skip to content

Commit

Permalink
Fix HasExcerpt failing on some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-layson committed Apr 8, 2024
1 parent 1008439 commit 52fa5fb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Filament/Traits/HasExcerpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ public function excerpt(): Attribute
$paragraph = '';
foreach ($content as $key => $value) {
if ($value['type'] === 'paragraph') {
$paragraph = $value['content'][0]['text']; // take the first part
if (isset($value['content'])) {
foreach ($value['content'] as $key => $valueContent) {
// find first instance of text
if (isset($valueContent['text'])) {
$paragraph = $valueContent['text']; // take the first part
break;
}
}
}
}
}

Expand Down

0 comments on commit 52fa5fb

Please sign in to comment.