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

Update SEOManager.php

This commit is contained in:
Mischa Sigtermans 2024-08-23 19:53:57 +02:00 committed by GitHub
parent 76d0f9efac
commit 1b44095163
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -184,23 +184,23 @@ class SEOManager
return $this->set('image', "https://s.useflipp.com/{$template}.png?s={$signature}&v={$query}"); return $this->set('image', "https://s.useflipp.com/{$template}.png?s={$signature}&v={$query}");
} }
/** Configure or use Previewify. */ /** Configure or use PreviewLinks. */
public function previewify(string $alias, int|string|array $data = null): string|static public function previewLinks(string $alias, int|string|array $data = null): string|static
{ {
if (is_string($data) || is_int($data)) { if (is_string($data) || is_int($data)) {
$this->meta("previewify.templates.$alias", (string) $data); $this->meta("previewlinks.templates.$alias", (string) $data);
return $this; return $this;
} }
if ($data === null) { if ($data === null) {
$data = [ $data = [
'previewify:title' => $this->raw('title'), 'previewlinks:title' => $this->raw('title'),
'previewify:description' => $this->raw('description'), 'previewlinks:description' => $this->raw('description'),
]; ];
} else { } else {
$data = array_combine( $data = array_combine(
array_map(fn ($key) => str_starts_with($key, 'previewify:') ? $key : "previewify:{$key}", array_keys($data)), array_map(fn ($key) => str_starts_with($key, 'previewlinks:') ? $key : "previewlinks:{$key}", array_keys($data)),
$data, $data,
); );
} }
@ -208,11 +208,11 @@ class SEOManager
$query = base64_encode(json_encode($data, JSON_THROW_ON_ERROR)); $query = base64_encode(json_encode($data, JSON_THROW_ON_ERROR));
/** @var string $template */ /** @var string $template */
$template = $this->meta("previewify.templates.$alias"); $template = $this->meta("previewlinks.templates.$alias");
$signature = hash_hmac('sha256', $query, config('services.previewify.key')); $signature = hash_hmac('sha256', $query, config('services.previewlinks.key'));
return $this->set('image', "https://previewify.app/generate/templates/{$template}/signed?signature={$signature}&fields={$query}"); return $this->set('image', "https://previewlinks.io/generate/templates/{$template}/signed?fields={$query}&signature={$signature}");
} }
/** Enable favicon extension. */ /** Enable favicon extension. */
@ -336,11 +336,11 @@ class SEOManager
*/ */
public function render(...$args): array|string|null public function render(...$args): array|string|null
{ {
// Flipp and Previewify support more arguments // Flipp and PreviewLinks support more arguments
if (in_array($args[0], ['flipp', 'previewify'], true)) { if (in_array($args[0], ['flipp', 'previewlinks'], true)) {
$method = array_shift($args); $method = array_shift($args);
// The `flipp` and `previewify` methods return image URLs // The `flipp` and `previewlinks` methods return image URLs
// so we don't sanitize the returned value with e() here // so we don't sanitize the returned value with e() here
return $this->{$method}(...$args); return $this->{$method}(...$args);
} }
@ -353,7 +353,7 @@ class SEOManager
// An array means we don't return anything, e.g. `@seo(['title' => 'foo']) // An array means we don't return anything, e.g. `@seo(['title' => 'foo'])
if (is_array($args[0])) { if (is_array($args[0])) {
foreach ($args[0] as $type => $value) { foreach ($args[0] as $type => $value) {
if (in_array($type, ['flipp', 'previewify'], true)) { if (in_array($type, ['flipp', 'previewlinks'], true)) {
$this->{$type}(...Arr::wrap($value)); $this->{$type}(...Arr::wrap($value));
} else { } else {
$this->set($type, $value); $this->set($type, $value);