generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7fad65
commit 7b1b8db
Showing
9 changed files
with
147 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Elegantly\Seo\Facades; | ||
|
||
use Elegantly\Seo\Contracts\HasSeo; | ||
use Elegantly\Seo\SeoData; | ||
use Elegantly\Seo\Unified\SeoUnifiedData; | ||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* @method static \Elegantly\Seo\SeoManager from(null|SeoData|SeoUnifiedData|\Elegantly\Seo\SeoManager|HasSeo $value = null) | ||
* | ||
* @see \Elegantly\Seo\Seo | ||
*/ | ||
class SeoManager extends Facade | ||
{ | ||
protected static function getFacadeAccessor(): string | ||
{ | ||
return \Elegantly\Seo\SeoManager::class; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Elegantly\Seo; | ||
|
||
use Elegantly\Seo\Schemas\Schema; | ||
use Elegantly\Seo\Standard\Alternate; | ||
use Elegantly\Seo\Unified\Image; | ||
use Elegantly\Seo\Unified\SeoUnifiedData; | ||
use Illuminate\Support\Facades\URL; | ||
|
||
class SeoData extends SeoUnifiedData | ||
{ | ||
public string $title; | ||
|
||
public string $canonical; | ||
|
||
/** | ||
* @param null|Alternate[] $alternates | ||
* @param null|Schema[] $schemas | ||
*/ | ||
public function __construct( | ||
?string $title = null, | ||
?string $canonical = null, | ||
public ?string $description = null, | ||
public ?string $robots = null, | ||
public ?string $sitemap = null, | ||
public ?array $alternates = null, | ||
public ?Image $image = null, | ||
public ?string $locale = null, | ||
public ?array $schemas = null, | ||
public ?SeoTags $customTags = null, | ||
) { | ||
$this->title = $title ?? config('seo.title') ?? ''; | ||
$this->canonical = $canonical ?? URL::current(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
use Elegantly\Seo\Contracts\HasSeo; | ||
use Elegantly\Seo\SeoData; | ||
use Elegantly\Seo\SeoManager; | ||
use Elegantly\Seo\Unified\SeoUnifiedData; | ||
|
||
if (! function_exists('seo')) { | ||
function seo(null|SeoData|SeoUnifiedData|SeoManager|HasSeo $value): SeoManager | ||
{ | ||
return \Elegantly\Seo\Facades\SeoManager::from($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
use Elegantly\Seo\Facades\SeoManager; | ||
use Elegantly\Seo\SeoData; | ||
use Illuminate\Support\Facades\URL; | ||
|
||
it('renders default seo from config', function () { | ||
|
||
$data = new SeoData; | ||
|
||
$url = URL::current(); | ||
|
||
expect( | ||
$data->toTags()->toHtml() | ||
)->toBe(implode("\n", [ | ||
'<title >Laravel</title>', | ||
'<link rel="canonical" href="'.$url.'" />', | ||
'<meta property="og:type" content="website" />', | ||
'<meta property="og:title" content="Laravel" />', | ||
'<meta property="og:url" content="'.$url.'" />', | ||
'<meta name="twitter:card" content="summary" />', | ||
'<meta name="twitter:title" content="Laravel" />', | ||
])); | ||
}); | ||
|
||
it('renders default seo from config using Facade', function () { | ||
|
||
$data = SeoManager::from(); | ||
|
||
$url = URL::current(); | ||
|
||
expect( | ||
$data->toTags()->toHtml() | ||
)->toBe(implode("\n", [ | ||
'<title >Laravel</title>', | ||
'<link rel="canonical" href="'.$url.'" />', | ||
'<meta property="og:type" content="website" />', | ||
'<meta property="og:title" content="Laravel" />', | ||
'<meta property="og:url" content="'.$url.'" />', | ||
'<meta name="twitter:card" content="summary" />', | ||
'<meta name="twitter:title" content="Laravel" />', | ||
])); | ||
}); |