mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 09:54:03 +00:00
Allow setting tag('og:title', ...)
This commit is contained in:
parent
2480e532bf
commit
f6bb4e8f64
4 changed files with 34 additions and 3 deletions
|
|
@ -1,6 +1,11 @@
|
||||||
@if(seo('title'))
|
@if(seo('title'))
|
||||||
<title>@seo('title')</title>
|
<title>@seo('title')</title>
|
||||||
|
|
||||||
|
@if(seo()->hasTag('og:title'))
|
||||||
|
<meta property="og:title" content="@seo('og:title')" />
|
||||||
|
@else
|
||||||
<meta property="og:title" content="@seo('title')" />
|
<meta property="og:title" content="@seo('title')" />
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if(seo('description'))
|
@if(seo('description'))
|
||||||
|
|
|
||||||
|
|
@ -42,5 +42,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true
|
"prefer-stable": true,
|
||||||
|
"config": {
|
||||||
|
"allow-plugins": {
|
||||||
|
"pestphp/pest-plugin": true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,18 @@ class SEOManager
|
||||||
return $this->tags;
|
return $this->tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Has a specific tag been set? */
|
||||||
|
public function hasRawTag(string $key): bool
|
||||||
|
{
|
||||||
|
return array_key_exists($key, $this->tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Has a specific meta tag been set? */
|
||||||
|
public function hasTag(string $property): bool
|
||||||
|
{
|
||||||
|
return $this->hasRawTag("meta.{$property}");
|
||||||
|
}
|
||||||
|
|
||||||
/** Add a head tag. */
|
/** Add a head tag. */
|
||||||
public function rawTag(string $key, string $tag = null): static
|
public function rawTag(string $key, string $tag = null): static
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -127,3 +127,12 @@ test('canonical url can be changed', function () {
|
||||||
->toContain('<meta property="og:url" content="http://foo.com/bar" />')
|
->toContain('<meta property="og:url" content="http://foo.com/bar" />')
|
||||||
->toContain('<link rel="canonical" href="http://foo.com/bar" />');
|
->toContain('<link rel="canonical" href="http://foo.com/bar" />');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('og:title can be overridden as a tag', function () {
|
||||||
|
seo()->title('foo')
|
||||||
|
->tag('og:title', 'bar');
|
||||||
|
|
||||||
|
expect(meta())
|
||||||
|
->toContain('<title>foo</title>')
|
||||||
|
->toContain('<meta property="og:title" content="bar" />');
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue