mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-17 03: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
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace ArchTech\SEO;
|
||||
|
||||
use ArchTech\SEO\Commands\GenerateFaviconsCommand;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use ImLiam\BladeHelper\BladeHelperServiceProvider;
|
||||
use ImLiam\BladeHelper\Facades\BladeHelper;
|
||||
|
|
@ -32,11 +33,11 @@ class SEOServiceProvider extends ServiceProvider
|
|||
], 'seo-views');
|
||||
|
||||
BladeHelper::directive('seo', function (...$args) {
|
||||
// Flipp supports more arguments
|
||||
if ($args[0] === 'flipp') {
|
||||
array_shift($args);
|
||||
// Flipp and Previewify support more arguments
|
||||
if (in_array($args[0], ['flipp', 'previewify'], true)) {
|
||||
$method = array_shift($args);
|
||||
|
||||
return seo()->flipp(...$args);
|
||||
return seo()->{$method}(...$args);
|
||||
}
|
||||
|
||||
// Two arguments indicate that we're setting a value, e.g. `@seo('title', 'foo')
|
||||
|
|
@ -46,7 +47,13 @@ class SEOServiceProvider extends ServiceProvider
|
|||
|
||||
// An array means we don't return anything, e.g. `@seo(['title' => 'foo'])
|
||||
if (is_array($args[0])) {
|
||||
seo($args[0]);
|
||||
foreach ($args[0] as $type => $value) {
|
||||
if (in_array($type, ['flipp', 'previewify'], true)) {
|
||||
seo()->{$type}(...Arr::wrap($value));
|
||||
} else {
|
||||
seo()->set($type, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue