Skip to content

Commit

Permalink
Merge pull request #27 from PortableStudios/fix/HasExcerpt-fix
Browse files Browse the repository at this point in the history
Fix HasExcerpt failing on some cases
  • Loading branch information
kyoungportable authored Apr 8, 2024
2 parents 9a9150a + 52fa5fb commit 92c91cc
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 92c91cc

Please sign in to comment.