Skip to content

Commit

Permalink
Screw you Elon
Browse files Browse the repository at this point in the history
Removing Twitter specific meta tags and social images. Should fallback to the default OG spec tags.
  • Loading branch information
robdekort committed Aug 22, 2023
1 parent 5075cd8 commit ec83c39
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 90 deletions.
24 changes: 0 additions & 24 deletions resources/fieldsets/globals_seo_social_defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,3 @@ fields:
instructions_position: below
instructions: 'The default OG image. Can be overridden per entry. The recommended size is 1200px x 630px. This image will be focal cropped to this dimension.'
width: 50
-
handle: twitter_image
field: common.image
config:
container: social_images
localizable: true
listable: hidden
display: 'Twitter image'
instructions_position: below
instructions: 'The default Twitter image. Can be overridden per entry. Images should have an aspect ratio of 2:1 with minimum dimensions of 300x157. This image will be focal cropped to this dimension.'
width: 50
-
handle: twitter_handle
field:
listable: hidden
display: 'Twitter handle'
width: 50
input_type: text
type: text
localizable: true
instructions: 'The Twitter user name that should be included with Twitter Card tags.'
instructions_position: below
prepend: '@'
antlers: false
11 changes: 0 additions & 11 deletions resources/fieldsets/seo_open_graph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,3 @@ fields:
instructions: "This entry's OG image. Defaults to global site OG image. The recommended size is 1200px x 630px. The image will be focal cropped to this dimension."
instructions_position: below
width: 50
-
handle: twitter_image
field: common.image
config:
mode: grid
container: social_images
listable: hidden
display: 'Twitter image'
instructions: "This entry's Twitter image. Defaults to global site Twitter image. Images should have an aspect ratio of 2:1 with minimum dimensions of 300x157. This image will be focal cropped to this dimension."
instructions_position: below
width: 50
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#
@name Fallback description
@desc Get the fallback description for meta, og and twitter.
@desc Get the fallback description for meta and og.
#}}

{{ seo:collection_defaults | where('collection', {collection}) }}
Expand Down
33 changes: 0 additions & 33 deletions resources/views/snippets/_seo.antlers.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,39 +142,6 @@
<meta property="og:image" content="{{ glide:seo:og_image width='1200' height='630' fit='crop_focal' absolute="true" }}">
{{ /if }}
{{# Twitter #}}
{{ if twitter_image or seo:twitter_image }}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="{{ seo:twitter_handle }}">
{{ if og_title }}
<meta name="twitter:title" content="{{ og_title | strip_tags | entities | trim }}">
{{ else }}
<meta name="twitter:title" content="{{ seo_title ? (seo_title | strip_tags | entities | trim) : (title | strip_tags | entities | trim) }}">
{{ /if }}
{{ if og_description }}
<meta name="twitter:description" content="{{ og_description | strip_tags | entities | trim }}">
{{ elseif seo_description }}
<meta name="twitter:description" content="{{ seo_description | strip_tags | entities | trim }}">
{{ elseif seo:collection_defaults }}
<meta name="twitter:description" content="{{ partial:statamic-peak-seo::snippets/fallback_description }}">
{{ /if }}
{{ if twitter_image }}
<meta name="twitter:image" content="{{ glide:twitter_image width='1200' height='600' fit='crop_focal' absolute="true" }}">
{{ asset :url="twitter_image" }}
{{ if alt }}
<meta name="twitter:image:alt" content="{{ alt ensure_right='.' }}">
{{ /if }}
{{ /asset }}
{{ elseif seo:twitter_image }}
<meta name="twitter:image" content="{{ glide:seo:twitter_image width='1200' height='600' fit='crop_focal' absolute="true" }}">
{{ asset :url="seo:twitter_image" }}
{{ if alt }}
<meta name="twitter:image:alt" content="{{ alt ensure_right='.' }}">
{{ /if }}
{{ /asset }}
{{ /if }}
{{ /if }}
{{# Trackers #}}
{{ if
(environment == 'local' && seo:trackers_local) or
Expand Down
8 changes: 2 additions & 6 deletions resources/views/social_images.antlers.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#
@name Social Images
@desc The template for generating Social Images. By default two sizes, one for the regular OG protocol and one for Twitter.
@desc The template for generating Social Images. By default it includes the size for the OG protocol.
#}}

<!-- statamic-peak-seo::social_images.antlers.html -->
Expand All @@ -24,11 +24,7 @@ <h2 class="mb-4 text-xs text-neutral font-bold uppercase tracking-widest">OG</h2
{{ partial:statamic-peak-seo::components/social_image selector="og" style="width: 1200px; height: 630px" }}
</div>
{{# The Twitter template. #}}
<div>
<h2 class="mb-4 text-xs text-neutral font-bold uppercase tracking-widest">Twitter</h2>
{{ partial:statamic-peak-seo::components/social_image selector="twitter" style="width: 1200px; height: 600px" }}
</div>
{{# Repeat for future OG sizes. RIP Twitter. #}}
</body>
</html>
<!-- End: statamic-peak-seo::social_images.antlers.html -->
16 changes: 1 addition & 15 deletions src/Jobs/GenerateSocialImagesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function handle()
// Delete any old images/meta remaining.
collect([
$this->item->get('og_image'),
$this->item->get('twitter_image'),
])
->filter()
->unique()
Expand All @@ -68,7 +67,6 @@ public function handle()

// Generate, save and set default og image/meta.
$file = "{$title}-og-{$unique}.png";

$image = $this->setupBrowsershot()
->windowSize(1200, 630)
->select('#og')
Expand All @@ -81,19 +79,7 @@ public function handle()
$container->makeAsset($file)->save();
$this->item->set('og_image', $file)->save();

// Generate, save and set default twitter image/meta.
$file = "{$title}-twitter-{$unique}.png";
$image = $this->setupBrowsershot()
->windowSize(1200, 600)
->select('#twitter')
->waitUntilNetworkIdle();
if (strtolower(config("filesystems.disks.{$container->disk}.driver") == 's3')) {
$disk->put($file, $image->screenshot());
} else {
$image->save($disk->path($file));
}
$container->makeAsset($file)->save();
$this->item->set('twitter_image', $file)->save();
// Repeat for other sizes.

Artisan::call('cache:clear');
}
Expand Down

0 comments on commit ec83c39

Please sign in to comment.