Skip to content

Commit a947efb

Browse files
authored
Update example to handle missing content gracefully
1 parent f72435a commit a947efb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use JackSleight\StatamicBardMutator\Facades\Mutator;
4343

4444
Mutator::html('heading', function ($value, $item) {
4545
if ($item->attrs->level === 2) {
46-
$value[1]['id'] = str_slug(collect($item->content)->implode('text', ''));
46+
$value[1]['id'] = str_slug(collect($item->content ?? [])->implode('text', ''));
4747
}
4848
return $value;
4949
});
@@ -202,4 +202,4 @@ Statamic includes a set of [modifiers](https://statamic.dev/modifiers) that can
202202
{{ headings }}
203203
<a href="#{{ content | bard_text | slugify }}">{{ content | bard_html }}</a>
204204
{{ /headings }}
205-
```
205+
```

0 commit comments

Comments
 (0)