1
0
Fork 0
mirror of https://github.com/archtechx/laravel-seo.git synced 2025-12-12 09:54:03 +00:00

Add Previewify image provider (#20)

* Add previewify image provider

* feat: support for setting image with the @seo blade tag (resolves #22)
This commit is contained in:
Tobias Petry 2022-06-11 20:17:48 +02:00 committed by GitHub
parent 9ce6843879
commit cf8ec8d3ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 162 additions and 7 deletions

View file

@ -181,6 +181,32 @@ class SEOManager
return $this->set('image', "https://s.useflipp.com/{$template}.png?s={$signature}&v={$query}");
}
/** Configure or use Previewify. */
public function previewify(string $alias, int|string|array $data = null): string|static
{
if (is_string($data) || is_int($data)) {
$this->meta("previewify.templates.$alias", (string) $data);
return $this;
}
if ($data === null) {
$data = [
'title' => $this->raw('title'),
'description' => $this->raw('description'),
];
}
$query = base64_encode(json_encode($data, JSON_THROW_ON_ERROR));
/** @var string $template */
$template = $this->meta("previewify.templates.$alias");
$signature = hash_hmac('sha256', $query, config('services.previewify.key'));
return $this->set('image', "https://previewify.app/generate/templates/{$template}/signed?signature={$signature}&fields={$query}");
}
/** Enable favicon extension. */
public function favicon(): static
{