diff --git a/assets/views/components/meta.blade.php b/assets/views/components/meta.blade.php index cdb618f..e15a13b 100644 --- a/assets/views/components/meta.blade.php +++ b/assets/views/components/meta.blade.php @@ -1,11 +1,10 @@ @if(seo('title')) @seo('title') - @if(seo()->hasTag('og:title')) - - @else + @unless(seo()->hasTag('og:title')) + {{-- If an og:title tag is provided directly, it's included in the @foreach below --}} - @endif + @endunless @endif @if(seo('description')) @@ -13,7 +12,10 @@ @endif - +@unless(seo()->hasTag('og:type')) + {{-- If an og:type tag is provided directly, it's included in the @foreach below --}} + +@endunless @if(seo('site')) @endif diff --git a/src/SEOManager.php b/src/SEOManager.php index 9eb98a3..01294aa 100644 --- a/src/SEOManager.php +++ b/src/SEOManager.php @@ -204,7 +204,7 @@ class SEOManager /** Has a specific tag been set? */ public function hasRawTag(string $key): bool { - return array_key_exists($key, $this->tags); + return isset($this->tags[$key]) && ($this->tags[$key] !== null); } /** Has a specific meta tag been set? */ diff --git a/tests/Pest/ManagerTest.php b/tests/Pest/ManagerTest.php index 860cad6..31332b6 100644 --- a/tests/Pest/ManagerTest.php +++ b/tests/Pest/ManagerTest.php @@ -128,7 +128,7 @@ test('canonical url can be changed', function () { ->toContain(''); }); -test('og:title can be overridden as a tag', function () { +test('og:title can be overridden using a tag', function () { seo()->title('foo') ->tag('og:title', 'bar'); @@ -136,3 +136,11 @@ test('og:title can be overridden as a tag', function () { ->toContain('foo') ->toContain(''); }); + +test('og:type can be overridden using a tag', function () { + expect(meta())->toContain(''); // default + + seo()->tag('og:type', 'foo'); + + expect(meta())->toContain(''); // overridden +});