diff --git a/src/SEOServiceProvider.php b/src/SEOServiceProvider.php index 1fd36af..6c0ce03 100644 --- a/src/SEOServiceProvider.php +++ b/src/SEOServiceProvider.php @@ -25,16 +25,26 @@ class SEOServiceProvider extends ServiceProvider ], 'seo-views'); BladeHelper::directive('seo', function (...$args) { + // Flipp supports more arguments + if ($args[0] === 'flipp') { + array_shift($args); + + return seo()->flipp(...$args); + } + + // Two arguments indicate that we're setting a value, e.g. `@seo('title', 'foo') if (count($args) === 2) { return seo()->set($args[0], $args[1]); } + // An array means we don't return anything, e.g. `@seo(['title' => 'foo']) if (is_array($args[0])) { seo($args[0]); return null; } + // A single value means we fetch a value, e.g. `@seo('title') return seo()->get($args[0]); }); } diff --git a/tests/Pest/FlippTest.php b/tests/Pest/FlippTest.php index 05ad821..369e710 100644 --- a/tests/Pest/FlippTest.php +++ b/tests/Pest/FlippTest.php @@ -42,3 +42,11 @@ test('flipp images are used as the cover images', function () { expect(seo()->flipp('blog')) ->toBe(seo('image')); }); + +test('the blade directive can be used with flipp', function () { + seo()->flipp('blog', 'abc'); + + seo()->title('foo')->description('bar'); + + expect(blade("@seo('flipp', 'blog')"))->toBe(seo()->flipp('blog')); +});