diff --git a/src/SEOManager.php b/src/SEOManager.php index e5a6724..a18ad26 100644 --- a/src/SEOManager.php +++ b/src/SEOManager.php @@ -196,11 +196,11 @@ class SEOManager 'previewify:description' => $this->raw('description'), ]; } else { - $data = array_combine( - array_map(fn ($key) => "previewify:{$key}", array_keys($data)), - $data, - ); - } + $data = array_combine( + array_map(fn ($key) => str_starts_with($key, 'previewify:') ? $key : "previewify:{$key}", array_keys($data)), + $data, + ); + } $query = base64_encode(json_encode($data, JSON_THROW_ON_ERROR)); diff --git a/tests/Pest/PreviewifyTest.php b/tests/Pest/PreviewifyTest.php index 25a1db0..9ac59c8 100644 --- a/tests/Pest/PreviewifyTest.php +++ b/tests/Pest/PreviewifyTest.php @@ -18,7 +18,7 @@ test('previewify makes a request to the template not the alias', function () { test('previewify templates can be given data', function () { seo()->previewify('blog', 1); - expect(seo()->previewify('blog', ['title' => 'abc', 'excerpt' => 'def'])) + expect(seo()->previewify('blog', ['title' => 'abc', 'previewify:excerpt' => 'def'])) ->toContain('previewify.app/generate/templates/1') ->toContain(base64_encode(json_encode(['previewify:title' => 'abc', 'previewify:excerpt' => 'def']))); });