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

OpenGraph improvements (#17)

* Allow setting tag('og:title', ...)

* og:type overriding

* Add type()
This commit is contained in:
Samuel Štancl 2022-03-30 18:01:21 +02:00 committed by GitHub
parent 2480e532bf
commit 754b3936d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 5 deletions

View file

@ -13,6 +13,7 @@ use Illuminate\Support\Str;
* @method $this url(string $url = null, ...$args) Set the canonical URL.
* @method $this site(string $site = null, ...$args) Set the site name.
* @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 twitterSite(string $username = null, ...$args) Set the Twitter author.
* @method $this twitterTitle(string $title = null, ...$args) Set the Twitter title.
@ -53,7 +54,7 @@ class SEOManager
protected function getKeys(): array
{
return collect([
'site', 'title', 'image', 'description', 'url',
'site', 'title', 'image', 'description', 'url', 'type',
'twitter.site', 'twitter.title', 'twitter.image', 'twitter.description',
])
->merge(array_keys($this->defaults))
@ -201,6 +202,18 @@ class SEOManager
return $this->tags;
}
/** Has a specific tag been set? */
public function hasRawTag(string $key): bool
{
return isset($this->tags[$key]) && ($this->tags[$key] !== null);
}
/** Has a specific meta tag been set? */
public function hasTag(string $property): bool
{
return $this->hasRawTag("meta.{$property}");
}
/** Add a head tag. */
public function rawTag(string $key, string $tag = null): static
{