Skip to content

Commit

Permalink
Merge pull request #11 from visuellverstehen/10-fix-undefined-text-pr…
Browse files Browse the repository at this point in the history
…operty

fix: prevent call to undefined text property
  • Loading branch information
juliawarnke authored Nov 23, 2023
2 parents a5df5a4 + 1079c37 commit 8f17cf6
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 8f17cf6

Please sign in to comment.