From 2ae102fb806e71ab94d6905e902601e00977462f Mon Sep 17 00:00:00 2001 From: Nikita Koida Date: Mon, 27 May 2024 13:54:12 +0300 Subject: [PATCH 1/2] Adaptive html to inertia style --- src/SEOTools/Integrations/Inertia.php | 16 ++++++++++++++++ src/SEOTools/SEOTools.php | 7 ++++++- src/resources/config/seotools.php | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/SEOTools/Integrations/Inertia.php diff --git a/src/SEOTools/Integrations/Inertia.php b/src/SEOTools/Integrations/Inertia.php new file mode 100644 index 0000000..2da01f1 --- /dev/null +++ b/src/SEOTools/Integrations/Inertia.php @@ -0,0 +1,16 @@ +jsonLdMulti()->generate(); + if (config('seotools.inertia') === true) { + $html = app(Inertia::class)->convertHeadToInertiaStyle($html); + } + return ($minify) ? str_replace(PHP_EOL, '', $html) : $html; } } diff --git a/src/resources/config/seotools.php b/src/resources/config/seotools.php index 5c52398..a109d7c 100644 --- a/src/resources/config/seotools.php +++ b/src/resources/config/seotools.php @@ -4,6 +4,7 @@ */ return [ + 'inertia' => env('SEO_TOOLS_INERTIA', false), 'meta' => [ /* * The default configurations to be used by the meta generator. From dbe73b14e88bfb834b02e3b2e68416efb21e1353 Mon Sep 17 00:00:00 2001 From: Nikita Koida Date: Mon, 27 May 2024 14:27:10 +0300 Subject: [PATCH 2/2] Added unit tests --- tests/SEOTools/Integrations/InertiaTest.php | 66 +++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/SEOTools/Integrations/InertiaTest.php diff --git a/tests/SEOTools/Integrations/InertiaTest.php b/tests/SEOTools/Integrations/InertiaTest.php new file mode 100644 index 0000000..19114e5 --- /dev/null +++ b/tests/SEOTools/Integrations/InertiaTest.php @@ -0,0 +1,66 @@ +inertia = $this->app->make(Inertia::class); + } + + public function test_convert_meta_to_inertia_style() + { + $seo = ''; + + $expected = ''; + + $converted = $this->inertia->convertHeadToInertiaStyle($seo); + + $this->assertEquals($expected, $converted); + } + + public function test_convert_canonical_link_to_inertia_style() + { + $seo = ''; + + $expected = ''; + + $converted = $this->inertia->convertHeadToInertiaStyle($seo); + + $this->assertEquals($expected, $converted); + } + + public function test_convert_title_to_inertia_style() + { + $seo = 'Title'; + + $expected = 'Title'; + + $converted = $this->inertia->convertHeadToInertiaStyle($seo); + + $this->assertEquals($expected, $converted); + } + + public function test_convert_script_to_inertia_style() + { + $seo = ''; + + $expected = ''; + + $converted = $this->inertia->convertHeadToInertiaStyle($seo); + + $this->assertEquals($expected, $converted); + } +} \ No newline at end of file