mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 01:44:03 +00:00
Add type()
This commit is contained in:
parent
1450ce17a7
commit
94be0f7e06
3 changed files with 11 additions and 7 deletions
|
|
@ -12,10 +12,11 @@
|
||||||
<meta name="description" content="@seo('description')" />
|
<meta name="description" content="@seo('description')" />
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@unless(seo()->hasTag('og:type'))
|
@if(seo('type'))
|
||||||
{{-- If an og:type tag is provided directly, it's included in the @foreach below --}}
|
<meta property="og:type" content="@seo('type')" />
|
||||||
|
@else
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
@endunless
|
@endif
|
||||||
|
|
||||||
@if(seo('site')) <meta property="og:site_name" content="@seo('site')"> @endif
|
@if(seo('site')) <meta property="og:site_name" content="@seo('site')"> @endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ use Illuminate\Support\Str;
|
||||||
* @method $this url(string $url = null, ...$args) Set the canonical URL.
|
* @method $this url(string $url = null, ...$args) Set the canonical URL.
|
||||||
* @method $this site(string $site = null, ...$args) Set the site name.
|
* @method $this site(string $site = null, ...$args) Set the site name.
|
||||||
* @method $this image(string $url = null, ...$args) Set the cover image.
|
* @method $this image(string $url = null, ...$args) Set the cover image.
|
||||||
|
* @method $this type(string $type = null, ...$args) Set the page type.
|
||||||
* @method $this twitter(enabled $bool = true, ...$args) Enable the Twitter extension.
|
* @method $this twitter(enabled $bool = true, ...$args) Enable the Twitter extension.
|
||||||
* @method $this twitterSite(string $username = null, ...$args) Set the Twitter author.
|
* @method $this twitterSite(string $username = null, ...$args) Set the Twitter author.
|
||||||
* @method $this twitterTitle(string $title = null, ...$args) Set the Twitter title.
|
* @method $this twitterTitle(string $title = null, ...$args) Set the Twitter title.
|
||||||
|
|
@ -53,7 +54,7 @@ class SEOManager
|
||||||
protected function getKeys(): array
|
protected function getKeys(): array
|
||||||
{
|
{
|
||||||
return collect([
|
return collect([
|
||||||
'site', 'title', 'image', 'description', 'url',
|
'site', 'title', 'image', 'description', 'url', 'type',
|
||||||
'twitter.site', 'twitter.title', 'twitter.image', 'twitter.description',
|
'twitter.site', 'twitter.title', 'twitter.image', 'twitter.description',
|
||||||
])
|
])
|
||||||
->merge(array_keys($this->defaults))
|
->merge(array_keys($this->defaults))
|
||||||
|
|
|
||||||
|
|
@ -137,10 +137,12 @@ test('og:title can be overridden using a tag', function () {
|
||||||
->toContain('<meta property="og:title" content="bar" />');
|
->toContain('<meta property="og:title" content="bar" />');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('og:type can be overridden using a tag', function () {
|
test('type can be overridden using the type method', function () {
|
||||||
expect(meta())->toContain('<meta property="og:type" content="website" />'); // default
|
expect(meta())->toContain('<meta property="og:type" content="website" />'); // default
|
||||||
|
|
||||||
seo()->tag('og:type', 'foo');
|
seo()->type('foo');
|
||||||
|
|
||||||
expect(meta())->toContain('<meta property="og:type" content="foo" />'); // overridden
|
expect(meta())
|
||||||
|
->toContain('<meta property="og:type" content="foo" />') // overridden
|
||||||
|
->not()->toContain('website');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue