Skip to content

Commit 8f17cf6

Browse files
authored
Merge pull request #11 from visuellverstehen/10-fix-undefined-text-property
fix: prevent call to undefined text property
2 parents a5df5a4 + 1079c37 commit 8f17cf6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Nodes/Heading.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ public function renderHTML($node, $HTMLAttributes = [])
1818

1919
// Add slugified id to specific headlines.
2020
if (in_array($node->attrs->level, config('anchor-navigation.heading.levels', []))) {
21-
$HTMLAttributes['id'] = Str::slug($node->content[0]->text);
21+
22+
if (property_exists($node->content[0], 'text') && !is_null($node->content[0]->text)) {
23+
$HTMLAttributes['id'] = Str::slug($node->content[0]->text);
24+
}
2225
}
2326

2427
return [

0 commit comments

Comments
 (0)