Skip to content

Commit

Permalink
Add twitter:creator meta tag (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetry authored Jun 11, 2022
1 parent 754b393 commit 9ce6843
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ title(string $title)
description(string $description)
image(string $url)

twitterCreator(string $username)
twitterSite(string $username)
twitterTitle(string $title)
twitterDescription(string $description)
Expand Down
1 change: 1 addition & 0 deletions assets/views/components/extensions/twitter.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<meta name="twitter:card" content="summary_large_image">
@if(seo('twitter.creator')) <meta name="twitter:creator" content="@seo('twitter.creator')"> @endif
@if(seo('twitter.site')) <meta name="twitter:site" content="@seo('twitter.site')"> @endif
@if(seo('twitter.title')) <meta name="twitter:title" content="@seo('twitter.title')"> @endif
@if(seo('twitter.description')) <meta name="twitter:description" content="@seo('twitter.description')"> @endif
Expand Down
3 changes: 2 additions & 1 deletion src/SEOManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @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 twitterCreator(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 twitterDescription(string $description = null, ...$args) Set the Twitter description.
Expand Down Expand Up @@ -55,7 +56,7 @@ protected function getKeys(): array
{
return collect([
'site', 'title', 'image', 'description', 'url', 'type',
'twitter.site', 'twitter.title', 'twitter.image', 'twitter.description',
'twitter.creator', 'twitter.site', 'twitter.title', 'twitter.image', 'twitter.description',
])
->merge(array_keys($this->defaults))
->merge(array_keys($this->values))
Expand Down
2 changes: 1 addition & 1 deletion tests/Pest/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
test('when an extension is enabled, all of its keys are included in the resolved values', function () {
expect(seo()->twitter()->all())
->not()->toBeEmpty()
->toHaveKeys(['twitter.title', 'twitter.description', 'twitter.site', 'twitter.image']);
->toHaveKeys(['twitter.title', 'twitter.description', 'twitter.creator', 'twitter.site', 'twitter.image']);
});

test('extension keys can be set by prefixing the call with the extension name and using camelcase', function () {
Expand Down

0 comments on commit 9ce6843

Please sign in to comment.