diff --git a/src/SEOTools/Contracts/JsonLd.php b/src/SEOTools/Contracts/JsonLd.php index 3b428a8..7019313 100644 --- a/src/SEOTools/Contracts/JsonLd.php +++ b/src/SEOTools/Contracts/JsonLd.php @@ -34,6 +34,15 @@ public function addValue($key, $value); public function setType($type); /** + * @param string $name + * + * @return static + */ + public function setName($name); + + /** + * Alias of {@see setName()}. + * * @param string $title * * @return static diff --git a/src/SEOTools/JsonLd.php b/src/SEOTools/JsonLd.php index 6c005ce..b523565 100644 --- a/src/SEOTools/JsonLd.php +++ b/src/SEOTools/JsonLd.php @@ -19,7 +19,7 @@ class JsonLd implements JsonLdContract /** * @var string */ - protected $title = ''; + protected $name = ''; /** * @var string @@ -73,8 +73,8 @@ public function generate($minify = false) } - if (!empty($this->title)) { - $generated['name'] = $this->title; + if (!empty($this->name)) { + $generated['name'] = $this->name; } @@ -118,13 +118,21 @@ public function setType($type) /** * {@inheritdoc} */ - public function setTitle($title) + public function setName($name) { - $this->title = $title; + $this->name = $name; return $this; } + /** + * {@inheritdoc} + */ + public function setTitle($title) + { + return $this->setName($title); + } + /** * {@inheritdoc} */ diff --git a/src/SEOTools/SEOTools.php b/src/SEOTools/SEOTools.php index e9ff511..f83e81c 100644 --- a/src/SEOTools/SEOTools.php +++ b/src/SEOTools/SEOTools.php @@ -46,7 +46,7 @@ public function setTitle($title, $appendDefault = true) $this->metatags()->setTitle($title, $appendDefault); $this->opengraph()->setTitle($title); $this->twitter()->setTitle($title); - $this->jsonLd()->setTitle($title); + $this->jsonLd()->setName($title); return $this; } diff --git a/tests/SEOTools/JsonLdTest.php b/tests/SEOTools/JsonLdTest.php index c4b6225..7431130 100644 --- a/tests/SEOTools/JsonLdTest.php +++ b/tests/SEOTools/JsonLdTest.php @@ -24,6 +24,18 @@ protected function setUp(): void $this->jsonLd = $this->app->make('seotools.json-ld'); } + public function test_set_name() + { + $this->jsonLd->setName('Kamehamehaaaaaaaa'); + + $expected = '
'; + + $this->setRightAssertion($expected); + } + + /** + * @depends test_set_name + */ public function test_set_title() { $this->jsonLd->setTitle('Kamehamehaaaaaaaa');