diff --git a/config/seo.php b/config/seo.php
index 58af121..ab36852 100644
--- a/config/seo.php
+++ b/config/seo.php
@@ -16,6 +16,9 @@
//
'twitter' => true,
+
+ //
+ 'embedx' => true,
],
'description' => [
@@ -27,6 +30,9 @@
//
'twitter' => true,
+
+ //
+ 'embedx' => true,
],
'image' => [
@@ -38,6 +44,9 @@
//
'twitter' => true,
+
+ //
+ 'embedx' => true,
],
],
diff --git a/src/Services/Traits/ShorthandSetterTrait.php b/src/Services/Traits/ShorthandSetterTrait.php
index 784332b..9b6d6e7 100644
--- a/src/Services/Traits/ShorthandSetterTrait.php
+++ b/src/Services/Traits/ShorthandSetterTrait.php
@@ -44,6 +44,11 @@ public function title(string $title = null, bool $escape = true): self
Twitter::make()->name('title')->content($title, $escape)
);
+ $this->addIf(
+ $config['embedx'] ?? true,
+ Meta\EmbedX::make()->name('title')->content($title, $escape)
+ );
+
return $this;
}
@@ -74,6 +79,11 @@ public function description(string $description = null, bool $escape = true): se
Twitter::make()->name('description')->content($description, $escape)
);
+ $this->addIf(
+ $config['embedx'] ?? true,
+ Meta\EmbedX::make()->name('description')->content($description, $escape)
+ );
+
return $this;
}
@@ -104,6 +114,11 @@ public function image(string $image = null, bool $escape = true): self
Twitter::make()->name('image')->content($image, $escape)
);
+ $this->addIf(
+ $config['embedx'] ?? true,
+ Meta\EmbedX::make()->name('image')->content($image, $escape)
+ );
+
return $this;
}
@@ -155,6 +170,24 @@ public function og(string $property, $content = null, bool $escape = true): self
);
}
+ /**
+ * Add EmbedX struct.
+ *
+ * @see https://embedx.app
+ *
+ * @param string $property
+ * @param mixed|null $content
+ * @param bool $escape
+ *
+ * @return $this
+ */
+ public function embedx(string $property, $content = null, bool $escape = true): self
+ {
+ return $this->add(
+ Meta\EmbedX::make()->name($property)->content($content, $escape)
+ );
+ }
+
/**
* Add the meta charset struct.
*
diff --git a/src/Structs/Meta/EmbedX.php b/src/Structs/Meta/EmbedX.php
new file mode 100644
index 0000000..4c18312
--- /dev/null
+++ b/src/Structs/Meta/EmbedX.php
@@ -0,0 +1,29 @@
+addAttribute('name', "embedx:{$value}", $escape);
+
+ return $this;
+ }
+}
diff --git a/tests/ArrayFormatTest.php b/tests/ArrayFormatTest.php
index b8c8f0f..c7224d4 100644
--- a/tests/ArrayFormatTest.php
+++ b/tests/ArrayFormatTest.php
@@ -19,7 +19,7 @@ public function testTitleIndex()
'title' => 'Foo',
]);
- $this->assertCount(3, seo()->getStructs());
+ $this->assertCount(4, seo()->getStructs());
$this->assertInstanceOf(Title::class, $struct = seo()->getStruct(Title::class));
$this->assertEquals('Foo', (string) $struct->getBody());
@@ -37,6 +37,7 @@ public function testTitleIndexTagOnly()
'seo.shorthand.title.tag' => true,
'seo.shorthand.title.opengraph' => false,
'seo.shorthand.title.twitter' => false,
+ 'seo.shorthand.title.embedx' => false,
]);
seo()->addFromArray([
@@ -57,7 +58,7 @@ public function testDescriptionIndex()
'description' => 'Foo',
]);
- $this->assertCount(3, seo()->getStructs());
+ $this->assertCount(4, seo()->getStructs());
$this->assertInstanceOf(Description::class, $struct = seo()->getStruct(Description::class));
$this->assertEquals('Foo', (string) $struct->getComputedAttribute('content'));
@@ -75,6 +76,7 @@ public function testDescriptionIndexTagOnly()
'seo.shorthand.description.tag' => true,
'seo.shorthand.description.opengraph' => false,
'seo.shorthand.description.twitter' => false,
+ 'seo.shorthand.description.embedx' => false,
]);
seo()->addFromArray([
diff --git a/tests/ShorthandSettersTest.php b/tests/ShorthandSettersTest.php
index d66b679..fc69a1a 100644
--- a/tests/ShorthandSettersTest.php
+++ b/tests/ShorthandSettersTest.php
@@ -17,6 +17,7 @@ public function testTitleSingleSetter()
'seo.shorthand.title.tag' => true,
'seo.shorthand.title.twitter' => false,
'seo.shorthand.title.opengraph' => false,
+ 'seo.shorthand.title.embedx' => false,
]);
seo()->title('My Title');
@@ -32,13 +33,14 @@ public function testTitleMultipleSetter()
'seo.shorthand.title.tag' => true,
'seo.shorthand.title.twitter' => true,
'seo.shorthand.title.opengraph' => true,
+ 'seo.shorthand.title.embedx' => true,
]);
seo()->title('My Title');
$contents = seo()->render()->toArray();
- $this->assertCount(3, $contents);
+ $this->assertCount(4, $contents);
}
public function testDescriptionSingleSetter()
@@ -47,6 +49,7 @@ public function testDescriptionSingleSetter()
'seo.shorthand.description.meta' => true,
'seo.shorthand.description.twitter' => false,
'seo.shorthand.description.opengraph' => false,
+ 'seo.shorthand.description.embedx' => false,
]);
seo()->description('My Description');
@@ -62,13 +65,14 @@ public function testDescriptionMultipleSetter()
'seo.shorthand.description.meta' => true,
'seo.shorthand.description.twitter' => true,
'seo.shorthand.description.opengraph' => true,
+ 'seo.shorthand.description.embedx' => true,
]);
seo()->description('My Description');
$contents = seo()->render()->toArray();
- $this->assertCount(3, $contents);
+ $this->assertCount(4, $contents);
}
public function testTwitterSetter()
@@ -93,6 +97,17 @@ public function testOpenGraphSetter()
$this->assertInstanceOf(OpenGraph::class, seo()->getStructs()[0]);
}
+ public function testEmbedXSetter()
+ {
+ seo()->embedx('title', 'My Site Name');
+
+ $contents = seo()->render()->toArray();
+
+ $this->assertCount(1, $contents);
+
+ $this->assertInstanceOf(Meta\EmbedX::class, seo()->getStructs()[0]);
+ }
+
public function testMetaSetter()
{
seo()->meta('author', 'My Little Pony');