Skip to content

Commit

Permalink
fix: prevent call to undefined text property
Browse files Browse the repository at this point in the history
  • Loading branch information
juliawarnke committed Nov 23, 2023
1 parent 5d369ed commit 1079c37
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Nodes/Heading.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public function renderHTML($node, $HTMLAttributes = [])

// Add slugified id to specific headlines.
if (in_array($node->attrs->level, config('anchor-navigation.heading.levels', []))) {
$HTMLAttributes['id'] = Str::slug($node->content[0]->text);

if (property_exists($node->content[0], 'text') && !is_null($node->content[0]->text)) {
$HTMLAttributes['id'] = Str::slug($node->content[0]->text);
}
}

return [
Expand Down

0 comments on commit 1079c37

Please sign in to comment.