diff --git a/assets/views/components/meta.blade.php b/assets/views/components/meta.blade.php index 2e4a964..ef747b4 100644 --- a/assets/views/components/meta.blade.php +++ b/assets/views/components/meta.blade.php @@ -5,6 +5,10 @@ @if(seo('description')) @endif @if(seo('image')) @endif +@foreach(seo()->tags() as $tag) + {!! $tag !!} +@endforeach + @foreach(seo()->extensions() as $extension) @endforeach diff --git a/src/SEOManager.php b/src/SEOManager.php index a8e0c72..90a8a84 100644 --- a/src/SEOManager.php +++ b/src/SEOManager.php @@ -37,6 +37,9 @@ class SEOManager /** Metadata for additional features. */ protected array $meta = []; + /** Extra head tags. */ + protected array $tags = []; + /** Get all used values. */ public function all(): array { @@ -169,6 +172,28 @@ class SEOManager return $this->set('image', "https://s.useflipp.com/{$template}.png?s={$signature}&v={$query}"); } + /** Get all extra head tags. */ + public function tags(): array + { + return $this->tags; + } + + /** Add a head tag. */ + public function rawTag(string $tag): static + { + $this->tags[] = $tag; + + return $this; + } + + /** Add a meta tag. */ + public function tag(string $property, string $content): static + { + $this->rawTag(""); + + return $this; + } + /** * Get or set metadata. * @param string|array $key The key or key-value pair being set. diff --git a/tests/Pest/ManagerTest.php b/tests/Pest/ManagerTest.php index 8ce5154..27b5257 100644 --- a/tests/Pest/ManagerTest.php +++ b/tests/Pest/ManagerTest.php @@ -82,3 +82,15 @@ test('thunks can be used as defaults', function () { test('setting the defaults returns the manager instance', function () { expect(seo()->title(default: 'foo'))->toBeInstanceOf(SEOManager::class); }); + +test('meta tags can be added to the template', function () { + seo()->tag('fb:image', 'foo'); + + expect(meta())->toContain(''); +}); + +test('raw tags can be added to the template', function () { + seo()->rawTag(''); + + expect(meta())->toContain(''); +});