Skip to content

Commit

Permalink
Merge pull request #13 from kristiana-s/fix-empty-heading-error
Browse files Browse the repository at this point in the history
add check for if content node exists
  • Loading branch information
juliawarnke authored May 22, 2024
2 parents 8f17cf6 + 33c862d commit 3370fb7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Nodes/Heading.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function renderHTML($node, $HTMLAttributes = [])
// Add slugified id to specific headlines.
if (in_array($node->attrs->level, config('anchor-navigation.heading.levels', []))) {

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

0 comments on commit 3370fb7

Please sign in to comment.