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

og:type overriding

This commit is contained in:
Samuel Štancl 2022-03-23 19:26:59 +01:00
parent f6bb4e8f64
commit 1450ce17a7
3 changed files with 17 additions and 7 deletions

View file

@ -1,11 +1,10 @@
@if(seo('title'))
<title>@seo('title')</title>
@if(seo()->hasTag('og:title'))
<meta property="og:title" content="@seo('og:title')" />
@else
@unless(seo()->hasTag('og:title'))
{{-- If an og:title tag is provided directly, it's included in the @foreach below --}}
<meta property="og:title" content="@seo('title')" />
@endif
@endunless
@endif
@if(seo('description'))
@ -13,7 +12,10 @@
<meta name="description" content="@seo('description')" />
@endif
<meta property="og:type" content="website" />
@unless(seo()->hasTag('og:type'))
{{-- If an og:type tag is provided directly, it's included in the @foreach below --}}
<meta property="og:type" content="website" />
@endunless
@if(seo('site')) <meta property="og:site_name" content="@seo('site')"> @endif

View file

@ -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? */

View file

@ -128,7 +128,7 @@ test('canonical url can be changed', function () {
->toContain('<link rel="canonical" href="http://foo.com/bar" />');
});
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('<title>foo</title>')
->toContain('<meta property="og:title" content="bar" />');
});
test('og:type can be overridden using a tag', function () {
expect(meta())->toContain('<meta property="og:type" content="website" />'); // default
seo()->tag('og:type', 'foo');
expect(meta())->toContain('<meta property="og:type" content="foo" />'); // overridden
});