Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate twitter properties with name HTML attribute instead of property #19

Merged
merged 3 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"php": "^7.4"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 16 additions & 0 deletions src/TwitterProperty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Astrotomic\OpenGraph;

class TwitterProperty extends Property
{
/** @var string */
protected $prefix = 'twitter';

public function __toString(): string
{
$content = str_replace('"', '&quot;', $this->content);

return "<meta name=\"{$this->prefix}:{$this->property}\" content=\"{$content}\">";
}
}
10 changes: 10 additions & 0 deletions src/TwitterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@ public function image(string $image, ?string $alt = null)

return $this;
}

public function setProperty(string $prefix, string $property, string $content)
{
$this->tags[$prefix.':'.$property] = TwitterProperty::make($prefix, $property, $content);
}

public function addProperty(string $prefix, string $property, string $content)
{
$this->tags[] = TwitterProperty::make($prefix, $property, $content);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:googleplay" content="AppName">
<meta property="twitter:app:id:googleplay" content="id123456789">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:googleplay" content="AppName">
<meta name="twitter:app:id:googleplay" content="id123456789">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:googleplay" content="AppName">
<meta property="twitter:app:id:googleplay" content="id123456789">
<meta property="twitter:app:url:googleplay" content="https://app.domainname.com">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:googleplay" content="AppName">
<meta name="twitter:app:id:googleplay" content="id123456789">
<meta name="twitter:app:url:googleplay" content="https://app.domainname.com">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:googleplay" content="AppName">
<meta property="twitter:app:id:googleplay" content="id123456789">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:googleplay" content="AppName">
<meta name="twitter:app:id:googleplay" content="id123456789">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:googleplay" content="AppName">
<meta property="twitter:app:id:googleplay" content="id123456789">
<meta property="twitter:app:url:googleplay" content="https://app.domainname.com">
<meta property="twitter:app:country" content="HR">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:googleplay" content="AppName">
<meta name="twitter:app:id:googleplay" content="id123456789">
<meta name="twitter:app:url:googleplay" content="https://app.domainname.com">
<meta name="twitter:app:country" content="HR">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:googleplay" content="AppName">
<meta property="twitter:app:id:googleplay" content="id123456789">
<meta property="twitter:app:url:googleplay" content="https://app.domainname.com">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:googleplay" content="AppName">
<meta name="twitter:app:id:googleplay" content="id123456789">
<meta name="twitter:app:url:googleplay" content="https://app.domainname.com">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:ipad" content="AppName">
<meta property="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta property="twitter:app:url:ipad" content="https://app.domainname.com">
<meta property="twitter:app:name:iphone" content="AppName">
<meta property="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta property="twitter:app:url:iphone" content="https://app.domainname.com">
<meta property="twitter:app:name:googleplay" content="AppName">
<meta property="twitter:app:id:googleplay" content="id123456789">
<meta property="twitter:app:url:googleplay" content="https://app.domainname.com">
<meta property="twitter:app:country" content="HR">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:ipad" content="AppName">
<meta name="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta name="twitter:app:url:ipad" content="https://app.domainname.com">
<meta name="twitter:app:name:iphone" content="AppName">
<meta name="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta name="twitter:app:url:iphone" content="https://app.domainname.com">
<meta name="twitter:app:name:googleplay" content="AppName">
<meta name="twitter:app:id:googleplay" content="id123456789">
<meta name="twitter:app:url:googleplay" content="https://app.domainname.com">
<meta name="twitter:app:country" content="HR">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:ipad" content="AppName">
<meta property="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:ipad" content="AppName">
<meta name="twitter:app:id:ipad" content="A1B2C3D4E5">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:ipad" content="AppName">
<meta property="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta property="twitter:app:url:ipad" content="https://app.domainname.com">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:ipad" content="AppName">
<meta name="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta name="twitter:app:url:ipad" content="https://app.domainname.com">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:ipad" content="AppName">
<meta property="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:ipad" content="AppName">
<meta name="twitter:app:id:ipad" content="A1B2C3D4E5">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:ipad" content="AppName">
<meta property="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta property="twitter:app:url:ipad" content="https://app.domainname.com">
<meta property="twitter:app:country" content="HR">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:ipad" content="AppName">
<meta name="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta name="twitter:app:url:ipad" content="https://app.domainname.com">
<meta name="twitter:app:country" content="HR">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:ipad" content="AppName">
<meta property="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta property="twitter:app:url:ipad" content="https://app.domainname.com">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:ipad" content="AppName">
<meta name="twitter:app:id:ipad" content="A1B2C3D4E5">
<meta name="twitter:app:url:ipad" content="https://app.domainname.com">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:iphone" content="AppName">
<meta property="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:iphone" content="AppName">
<meta name="twitter:app:id:iphone" content="A1B2C3D4E5">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:iphone" content="AppName">
<meta property="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta property="twitter:app:url:iphone" content="https://app.domainname.com">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:iphone" content="AppName">
<meta name="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta name="twitter:app:url:iphone" content="https://app.domainname.com">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:iphone" content="AppName">
<meta property="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:iphone" content="AppName">
<meta name="twitter:app:id:iphone" content="A1B2C3D4E5">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:iphone" content="AppName">
<meta property="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta property="twitter:app:url:iphone" content="https://app.domainname.com">
<meta property="twitter:app:country" content="HR">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:iphone" content="AppName">
<meta name="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta name="twitter:app:url:iphone" content="https://app.domainname.com">
<meta name="twitter:app:country" content="HR">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<html><head>
<meta property="twitter:card" content="app">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:app:name:iphone" content="AppName">
<meta property="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta property="twitter:app:url:iphone" content="https://app.domainname.com">
<meta name="twitter:card" content="app">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:app:name:iphone" content="AppName">
<meta name="twitter:app:id:iphone" content="A1B2C3D4E5">
<meta name="twitter:app:url:iphone" content="https://app.domainname.com">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head>
<meta property="twitter:card" content="player">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:image" content="http://www.example.com/image1.jpg">
<meta property="twitter:image:alt" content="Image alternate text">
<meta property="twitter:player" content="http://www.example.com/player.iframe">
<meta property="twitter:player:width" content="1920">
<meta property="twitter:player:height" content="1080">
<meta name="twitter:card" content="player">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:image" content="http://www.example.com/image1.jpg">
<meta name="twitter:image:alt" content="Image alternate text">
<meta name="twitter:player" content="http://www.example.com/player.iframe">
<meta name="twitter:player:width" content="1920">
<meta name="twitter:player:height" content="1080">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head>
<meta property="twitter:card" content="summary">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:image" content="http://www.example.com/image1.jpg">
<meta property="twitter:image:alt" content="Image alternate text">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:image" content="http://www.example.com/image1.jpg">
<meta name="twitter:image:alt" content="Image alternate text">
</head></html>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head>
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:title" content="Title | Example">
<meta property="twitter:description" content="Description">
<meta property="twitter:site" content="@astrotomic_oss">
<meta property="twitter:creator" content="@devgummibeer">
<meta property="twitter:image" content="http://www.example.com/image1.jpg">
<meta property="twitter:image:alt" content="Image alternate text">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Title | Example">
<meta name="twitter:description" content="Description">
<meta name="twitter:site" content="@astrotomic_oss">
<meta name="twitter:creator" content="@devgummibeer">
<meta name="twitter:image" content="http://www.example.com/image1.jpg">
<meta name="twitter:image:alt" content="Image alternate text">
</head></html>
Loading