mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 01:44:03 +00:00
Merge be53cea433 into 0a2eef4db4
This commit is contained in:
commit
e665173cec
3 changed files with 37 additions and 4 deletions
|
|
@ -1,2 +1,6 @@
|
|||
@if ($favicon = seo('favicon'))
|
||||
<link rel="icon" href="{{ $favicon }}">
|
||||
@else
|
||||
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}">
|
||||
<link rel="icon" type="image/png" href="{{ asset('favicon.png') }}">
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -216,9 +216,13 @@ class SEOManager
|
|||
}
|
||||
|
||||
/** Enable favicon extension. */
|
||||
public function favicon(): static
|
||||
public function favicon(string|bool $value = true): static
|
||||
{
|
||||
$this->extensions['favicon'] = true;
|
||||
if (is_string($value) && !empty($value)) {
|
||||
$this->set('favicon', $value);
|
||||
}
|
||||
|
||||
$this->extensions['favicon'] = !!$value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,3 +41,28 @@ test('it should fail because the from path is incorrect', function () {
|
|||
assertFileDoesNotExist(public_path('favicon.ico'));
|
||||
assertFileDoesNotExist(public_path('favicon.png'));
|
||||
});
|
||||
|
||||
test('it should have custom value with non-empty string', function () {
|
||||
seo()->favicon('foo');
|
||||
|
||||
expect(seo('favicon'))->toBe('foo');
|
||||
expect(meta())->toContain('<link rel="icon" href="foo">');
|
||||
});
|
||||
|
||||
test('it should not have custom value with empty string or false', function () {
|
||||
seo()->favicon('');
|
||||
|
||||
expect(seo('favicon'))->toBe(null);
|
||||
expect(meta())->not()->toContain('link rel="icon"');
|
||||
|
||||
expect(seo('favicon'))->toBe(null);
|
||||
expect(meta())->not()->toContain('link rel="icon"');
|
||||
});
|
||||
|
||||
test('it should have default favicon setup', function () {
|
||||
seo()->favicon();
|
||||
expect(seo('favicon'))->toBe(null);
|
||||
|
||||
expect(meta())->toContain('<link rel="icon" type="image/x-icon" href="http://localhost/favicon.ico">');
|
||||
expect(meta())->toContain('<link rel="icon" type="image/png" href="http://localhost/favicon.png">');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue