mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 01:44:03 +00:00
feat: support for setting image with the @seo blade tag (resolves #22)
This commit is contained in:
parent
d12038f207
commit
e6a41fc3fc
3 changed files with 22 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace ArchTech\SEO;
|
||||
|
||||
use ArchTech\SEO\Commands\GenerateFaviconsCommand;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use ImLiam\BladeHelper\BladeHelperServiceProvider;
|
||||
use ImLiam\BladeHelper\Facades\BladeHelper;
|
||||
|
|
@ -46,7 +47,13 @@ class SEOServiceProvider extends ServiceProvider
|
|||
|
||||
// An array means we don't return anything, e.g. `@seo(['title' => 'foo'])
|
||||
if (is_array($args[0])) {
|
||||
seo($args[0]);
|
||||
foreach ($args[0] as $type => $value) {
|
||||
if (in_array($type, ['flipp', 'previewify'], true)) {
|
||||
seo()->{$type}(...Arr::wrap($value));
|
||||
} else {
|
||||
seo()->set($type, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,3 +68,10 @@ test('flipp uses the raw title and description', function () {
|
|||
->toContain('s.useflipp.com/abcdefg')
|
||||
->toContain(base64_encode(json_encode(['title' => 'foo', 'description' => 'bar'])));
|
||||
});
|
||||
|
||||
test('the @seo helper can be used for setting a flipp image', function () {
|
||||
seo()->flipp('blog', 'abcdefg');
|
||||
blade("@seo(['flipp' => ['blog', ['title' => 'abc', 'excerpt' => 'def']]])");
|
||||
|
||||
expect(seo('image'))->toContain('s.useflipp.com/abcdefg');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -68,3 +68,10 @@ test('previewify uses the raw title and description', function () {
|
|||
->toContain('previewify.app/generate/templates/1')
|
||||
->toContain(base64_encode(json_encode(['title' => 'foo', 'description' => 'bar'])));
|
||||
});
|
||||
|
||||
test('the @seo helper can be used for setting a previewify image', function () {
|
||||
seo()->previewify('blog', 1);
|
||||
blade("@seo(['previewify' => ['blog', ['title' => 'abc', 'excerpt' => 'def']]])");
|
||||
|
||||
expect(seo('image'))->toContain('previewify.app/generate/templates/1');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue