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:
parent
9ce6843879
commit
cf8ec8d3ae
6 changed files with 162 additions and 7 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue