mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 09:54:03 +00:00
Make flipp use raw values
This commit is contained in:
parent
9cebfec4c8
commit
ab1e01b066
3 changed files with 33 additions and 3 deletions
|
|
@ -109,6 +109,16 @@ class SEOManager
|
|||
));
|
||||
}
|
||||
|
||||
/** Get a value without modifications. */
|
||||
public function raw(string $key): string|null
|
||||
{
|
||||
return isset($this->values[$key])
|
||||
? value($this->values[$key])
|
||||
: value($this->defaults[$key] ?? (
|
||||
Str::contains($key, '.') ? $this->get(Str::after($key, '.')) : null
|
||||
));
|
||||
}
|
||||
|
||||
/** Configure an extension. */
|
||||
public function extension(string $name, bool $enabled = true, string $view = null): static
|
||||
{
|
||||
|
|
@ -144,8 +154,8 @@ class SEOManager
|
|||
|
||||
if ($data === null) {
|
||||
$data = [
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'title' => $this->raw('title'),
|
||||
'description' => $this->raw('description'),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ test('the flipp method returns a link to a signed url', function () {
|
|||
seo()->flipp('blog', 'abcdefg');
|
||||
|
||||
expect(seo()->flipp('blog', ['title' => 'abc']))
|
||||
->toContain('?s=' . hash_hmac('sha256', 'blog' . base64_encode(json_encode(['title' => 'abc'])), config('services.flipp.key')));
|
||||
->toContain('?s=' . hash_hmac('sha256', 'abcdefg' . base64_encode(json_encode(['title' => 'abc'])), config('services.flipp.key')));
|
||||
});
|
||||
|
||||
test("flipp templates use default data when they're not passed any data explicitly", function () {
|
||||
|
|
@ -57,3 +57,14 @@ test('the blade directive can be used with flipp', function () {
|
|||
expect(blade("@seo('flipp', 'blog')"))->toBe(seo()->flipp('blog'));
|
||||
expect(blade("@seo('flipp', 'blog', ['title' => 'abc'])"))->toBe(seo()->flipp('blog', ['title' => 'abc']));
|
||||
});
|
||||
|
||||
test('flipp uses the raw title and description', function () {
|
||||
seo()->flipp('blog', 'abcdefg');
|
||||
|
||||
seo()->title(modify: fn (string $title) => $title . ' - modified');
|
||||
seo()->title('foo')->description('bar');
|
||||
|
||||
expect(seo()->flipp('blog'))
|
||||
->toContain('s.useflipp.com/abcdefg')
|
||||
->toContain(base64_encode(json_encode(['title' => 'foo', 'description' => 'bar'])));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,3 +19,12 @@ test('modifiers are not applied on default values', function () {
|
|||
|
||||
expect(seo('title'))->toBe('ArchTech — Web development agency');
|
||||
});
|
||||
|
||||
test('modifiers can be bypassed by using the raw method', function () {
|
||||
seo()->title(modify: fn (string $title) => $title . ' | ArchTech');
|
||||
|
||||
seo()->title('About us');
|
||||
|
||||
expect(seo()->get('title'))->toBe('About us | ArchTech');
|
||||
expect(seo()->raw('title'))->toBe('About us');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue