Skip to content

Commit

Permalink
Fix social images live preview (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni authored May 24, 2024
1 parent 5994096 commit 2de72a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/SocialImages/SocialImageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public function twitter(Entry $entry): SocialImage
return new SocialImage($entry, $this->findModel("twitter_{$entry->seo_twitter_card}"));
}

public function previewTargets(): array
public function previewTargets(Entry $entry): array
{
return [
[
'label' => 'Open Graph Image',
'format' => $this->route(theme: '{seo_social_images_theme}', type: 'open_graph', id: '{id}'),
'format' => $this->route(theme: $entry->seo_social_images_theme, type: 'open_graph', id: '{id}'),
],
[
'label' => 'Twitter Image',
'format' => $this->route(theme: '{seo_social_images_theme}', type: 'twitter_{seo_twitter_card}', id: '{id}'),
'format' => $this->route(theme: $entry->seo_social_images_theme, type: "twitter_{$entry->seo_twitter_card}", id: '{id}'),
],
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Subscribers/SocialImagesGeneratorSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public function addPreviewTargets(Event $event): void
}

// TODO: This has to change when implementing for taxonomies.
$this->getProperty($event)?->collection()->addPreviewTargets(SocialImage::previewTargets());
$this->getProperty($event)?->collection()->addPreviewTargets(SocialImage::previewTargets($event->entry));
}
}

0 comments on commit 2de72a9

Please sign in to comment.