Skip to content

Commit 3b6a1dc

Browse files
committed
feature #1918 [Site] Improve social meta (smnandre)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Site] Improve social meta Follows #1907 Commits ------- 59f1cbc [Site] Improve social meta
2 parents 7a8f6b4 + 59f1cbc commit 3b6a1dc

25 files changed

+100
-69
lines changed
Loading
Loading
Loading
Loading
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

ux.symfony.com/src/Model/UxPackage.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct(
2424
private string $route,
2525
private string $color,
2626
private string $gradient,
27+
private string $tagLine,
2728
private string $description,
2829
private string $createString,
2930
private ?string $imageFileName = null,
@@ -55,9 +56,14 @@ public function getGradient(): string
5556
return $this->gradient;
5657
}
5758

58-
public function getImageFilename(): string
59+
public function getImageFilename(?string $format = null): string
5960
{
60-
return $this->imageFileName ?? ltrim($this->name, 'ux-').'.png';
61+
return $this->imageFileName ?? ltrim($this->name, 'ux-').($format ? ('-'.$format) : '').'.png';
62+
}
63+
64+
public function getTagLine(): string
65+
{
66+
return $this->tagLine;
6167
}
6268

6369
public function getDescription(): string
@@ -120,4 +126,9 @@ public function getCreateString(): string
120126
{
121127
return $this->createString;
122128
}
129+
130+
public function getImage(?string $format = null): string
131+
{
132+
return 'images/ux_packages/'.$this->getImageFilename($format);
133+
}
123134
}

ux.symfony.com/src/Service/LiveDemoRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function findAll(): array
4646
),
4747
new LiveDemo(
4848
'live-memory',
49-
name: 'LiveMemory Card Game',
49+
name: 'Live Memory Card Game',
5050
description: 'A Memorable Game UX with Live Components!',
5151
route: 'app_demo_live_memory',
5252
longDescription: <<<EOF

ux.symfony.com/src/Service/UxPackageRepository.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function findAll(?string $query = null): array
2727
'app_turbo',
2828
'#5920A0',
2929
'linear-gradient(95deg, #5920A0 -5%, #844EC9 105%)',
30+
'Single-page Symfony app',
3031
'Integration with Turbo for single-page-app and real-time experience',
3132
'I need to transform my app into an SPA!'
3233
))
@@ -39,6 +40,7 @@ public function findAll(?string $query = null): array
3940
'app_live_component',
4041
'#D98A11',
4142
'linear-gradient(124deg, #BF5421, #D98A11)',
43+
'Interactive UI in PHP & Twig',
4244
'Build dynamic interfaces with zero JavaScript',
4345
'I need Twig templates that update in real-time!'
4446
),
@@ -49,6 +51,7 @@ public function findAll(?string $query = null): array
4951
'app_autocomplete',
5052
'#DF275E',
5153
'linear-gradient(95deg, #DF275E -5%, #E85995 105%)',
54+
'Ajax-powered Form Select',
5255
'Ajax-powered, auto-completable `select` elements',
5356
'I need an Ajax-autocomplete select field'
5457
),
@@ -59,6 +62,7 @@ public function findAll(?string $query = null): array
5962
'app_icons',
6063
'#fff',
6164
'linear-gradient(to bottom right, cyan, purple)',
65+
'SVG icons made easy',
6266
'Render SVG icons seamlessly from your Twig templates.',
6367
'I need to render SVG icons.',
6468
'icons.svg',
@@ -70,6 +74,7 @@ public function findAll(?string $query = null): array
7074
'app_chartjs',
7175
'#21A81E',
7276
'linear-gradient(95deg, #21A81E, #45DD42 108%)',
77+
'Interactive charts with Chart.js',
7378
'Easy charts with Chart.js',
7479
'I need to build a chart'
7580
))
@@ -81,6 +86,7 @@ public function findAll(?string $query = null): array
8186
'app_react',
8287
'#10A2CB',
8388
'linear-gradient(95deg, #10a2cb -5%, #42caf0 105%)',
89+
'Render React components from Twig',
8490
'Quickly render `<React />` components &amp; pass them props.',
8591
'I need to render React components from Twig'
8692
))
@@ -92,6 +98,7 @@ public function findAll(?string $query = null): array
9298
'app_vue',
9399
'#35b67c',
94100
'linear-gradient(95deg, #35B67C -5%, #8CE3BC 105%)',
101+
'Render Vue components from Twig',
95102
'Quickly render `<Vue />` components &amp; pass them props.',
96103
'I need to render Vue.js components from Twig'
97104
))
@@ -103,6 +110,7 @@ public function findAll(?string $query = null): array
103110
'app_svelte',
104111
'#FF3E00',
105112
'linear-gradient(115deg, #BE3030, #FF3E00)',
113+
'Render Svelte components from Twig',
106114
'Quickly render `<Svelte />` components &amp; pass them props.',
107115
'I need to render Svelte components from Twig',
108116
'svelte.svg',
@@ -115,6 +123,7 @@ public function findAll(?string $query = null): array
115123
'app_cropperjs',
116124
'#1E8FA8',
117125
'linear-gradient(136deg, #1E8FA8 -7%, #3FC0DC 105%)',
126+
'Form Tools for cropping images',
118127
'Form Type and tools for cropping images',
119128
'I need to add a JavaScript image cropper'
120129
))
@@ -126,6 +135,7 @@ public function findAll(?string $query = null): array
126135
'app_lazy_image',
127136
'#AC2777',
128137
'linear-gradient(136deg, #AC2777 -8%, #F246AD 105%)',
138+
'Delay Loading with Blurhash',
129139
'Optimize Image Loading with BlurHash',
130140
'I need to delay large image loading'
131141
),
@@ -136,6 +146,7 @@ public function findAll(?string $query = null): array
136146
'app_twig_component',
137147
'#7FA020',
138148
'linear-gradient(95deg, #7FA020 -5%, #A1C94E 105%)',
149+
'Render Reusable UI Elements',
139150
'Create PHP classes that can render themselves',
140151
'I need to create PHP classes that render'
141152
),
@@ -146,15 +157,18 @@ public function findAll(?string $query = null): array
146157
'app_dropzone',
147158
'#AC9F27',
148159
'linear-gradient(135deg, #AC9F27 -8%, #E8D210 105%)',
160+
'Upload Files with Style',
149161
'Form type for stylized "drop zone" for file uploads',
150162
'I need an upload field that looks great'
151163
),
164+
152165
(new UxPackage(
153166
'swup',
154167
'Swup Integration',
155168
'app_swup',
156169
'#D87036',
157170
'linear-gradient(95deg, #D87036 -5%, #EA9633 105%)',
171+
'Stylized Page Transitions',
158172
'Integration with the page transition library Swup',
159173
'I need stylized page transitions'
160174
))
@@ -166,6 +180,7 @@ public function findAll(?string $query = null): array
166180
'app_notify',
167181
'#204CA0',
168182
'linear-gradient(95deg, #204CA0 -6%, #3D82EA 105%)',
183+
'Native Browser Notifications',
169184
'Trigger native browser notifications from inside PHP',
170185
'I need to send browser notifications',
171186
),
@@ -176,6 +191,7 @@ public function findAll(?string $query = null): array
176191
'app_toggle_password',
177192
'#BE0404',
178193
'linear-gradient(142deg, #FD963C -15%, #BE0404 95%)',
194+
'Password Visibility Switch',
179195
'Switch the visibility of a password field',
180196
'I need to toggle the visibility of a password field',
181197
),
@@ -186,6 +202,7 @@ public function findAll(?string $query = null): array
186202
'app_typed',
187203
'#20A091',
188204
'linear-gradient(95deg, #20A091 -5%, #4EC9B3 105%)',
205+
'Animated Typing with Typed.js',
189206
'Animated typing with Typed.js',
190207
'I need to type onto the screen... like this'
191208
))
@@ -197,6 +214,7 @@ public function findAll(?string $query = null): array
197214
'app_translator',
198215
'#2248D0',
199216
'linear-gradient(139deg, #2248D0 -20%, #00FFB2 113%)',
217+
'Symfony Translations in JavaScript',
200218
"Use Symfony's translations in JavaScript",
201219
'I need to translate strings in JavaScript',
202220
'translator.svg'

ux.symfony.com/templates/_meta.html.twig

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,33 @@
33
<link rel="canonical" href="{{ meta.canonical }}">
44
{% endif %}
55

6-
<meta name="description" content="{% block description %}{{ meta.description|default|u.truncate(200, '...') }}{% endblock %}">
6+
<meta name="description" content="{% block description %}{{ meta.description|default|u.truncate(200, '...', false) }}{% endblock %}">
77

8-
{% set og_title = meta.og.title ?? meta.title ?? null %}
9-
{% if og_title %}
10-
<meta property="og:title" content="{{ og_title|u.truncate(55, '...') }}">
11-
{% endif %}
12-
{% set og_description = meta.og.description ?? meta.description ?? null %}
13-
{% if og_description %}
14-
<meta property="og:description" content="{{ og_description|u.truncate(160, '...') }}">
15-
{% endif %}
16-
{% set og_url = meta.og.url ?? meta.canonical ?? null %}
17-
{% if og_url %}
18-
<meta property="og:url" content="{{ absolute_url(og_url) }}">
19-
{% endif %}
20-
{% set image = meta.og.image ?? meta.image ?? null %}
21-
{% if image.url|default %}
22-
<meta property="og:image" content="{{ absolute_url(image.url) }}">
23-
<meta property="og:image:width" content="{{ image.width }}">
24-
<meta property="og:image:height" content="{{ image.height }}">
25-
<meta property="og:image:type" content="{{ image.type|default('image/png') }}">
26-
{% if image.alt|default %}
27-
<meta property="og:image:alt" content="{{ image.alt }}">
8+
{# META < META.SOCIAL #}
9+
{% set social = {
10+
title: meta.title,
11+
description: meta.description ?? '',
12+
image: meta.image ?? null,
13+
url: meta.canonical ?? null,
14+
}|merge(meta.social ?? {}) %}
15+
16+
{# META < META.SOCIAL < META.OG #}
17+
{% set og = social|merge(meta.og ?? {}) %}
18+
<meta property="og:title" content="{{ og.title|u.truncate(55, '...', false) }}">
19+
<meta property="og:description" content="{{ og.description|u.truncate(120, '...', false) }}">
20+
<meta property="og:url" content="{{ absolute_url(og.url) }}">
21+
<meta property="og:site_name" content="Symfony UX" />
22+
{% if og.image.url|default %}
23+
<meta property="og:image" content="{{ absolute_url(og.image.url) }}">
24+
{% if og.image.width|default and og.image.height|default %}
25+
<meta property="og:image:width" content="{{ og.image.width }}">
26+
<meta property="og:image:height" content="{{ og.image.height }}">
27+
{% endif %}
28+
{% if og.image.type|default %}
29+
<meta property="og:image:type" content="{{ og.image.type }}">
30+
{% endif %}
31+
{% if og.image.alt|default %}
32+
<meta property="og:image:alt" content="{{ og.image.alt }}">
2833
{% endif %}
2934
{% else %}
3035
<meta property="og:image" content="{{ absolute_url(asset('images/symfony-ux.png')) }}">
@@ -33,17 +38,20 @@
3338
<meta property="og:image:type" content="image/png">
3439
<meta property="og:image:alt" content="Symfony UX">
3540
{% endif %}
36-
<meta property="og:site_name" content="Symfony UX" />
3741

38-
{% if meta.tiwtter.title|default %}
39-
<meta name="twitter:title" content="{{ meta.twitter.title|u.truncate(55, '...') }}">
40-
{% endif %}
41-
{% if meta.twitter.description|default %}
42-
<meta name="twitter:description" content="{{ meta.twitter.description|u.truncate(160, '...') }}">
43-
{% endif %}
44-
{% set image = meta.twitter.image ?? meta.og.image ?? meta.image ?? null %}
45-
{% if image.url|default %}
46-
<meta name="twitter:image" content="{{ absolute_url(image.url) }}">
47-
<meta name=”twitter:cardcontent=”summary_large_image” />
42+
{# META < META.SOCIAL < META.TWITTER #}
43+
{% set twitter = social|merge(meta.twitter ?? {}) %}
44+
{% set twitter_card = twitter.image.width|default(0) > 1200 ? 'summary_large_image' : 'summary' %}
45+
<meta name="twitter:title" content="{{ twitter.title|u.truncate(55, '...', false) }}">
46+
<meta name="twitter:card" content="{{ twitter.card ?? twitter_card }}">
47+
<meta name="twitter:description" content="{{ twitter.description|u.truncate(120, '...', false) }}">
48+
<meta name="twitter:url" content="{{ absolute_url(twitter.url) }}">
49+
<meta name="twitter:creator" content="{{ twitter.creator ?? '@symfonyux' }}">
50+
<meta name="twitter:site" content="@symfonyux">
51+
{% if twitter.image.url|default %}
52+
<meta name="twitter:image" content="{{ absolute_url(twitter.image.url) }}">
53+
{% if twitter.image.width|default and twitter.image.height|default %}
54+
<meta name="twitter:image:width" content="{{ twitter.image.width }}">
55+
<meta name="twitter:image:height" content="{{ twitter.image.height }}">
56+
{% endif %}
4857
{% endif %}
49-
<meta name="twitter:site" content="@SymfonyUX">

ux.symfony.com/templates/demos/live_demo.html.twig

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22

33
{% set meta = {
44
title: demo.name,
5-
title_suffix: ' - Symfony UX Demo',
6-
description: demo.description,
7-
og: {
8-
title: demo.name ~ ' - Symfony UX Demo',
9-
description: demo.longDescription|striptags|u.truncate(200, '...')
10-
},
11-
image: {
12-
url: absolute_url(asset(demo.screenshotFilename('1280x720'))),
13-
width: 1280,
14-
height: 720,
15-
},
5+
title_suffix: ' - Live Component - Symfony UX',
6+
description: demo.description|striptags,
167
canonical: url(demo.route),
17-
twitter: {
18-
card: 'summary_large_image',
19-
}
8+
social: {
9+
title: demo.name ~ ' - Symfony UX',
10+
description: demo.longDescription|striptags,
11+
image: {
12+
url: absolute_url(asset(demo.screenshotFilename('1280x720'))),
13+
type: 'image/png',
14+
width: 1280,
15+
height: 720,
16+
alt: demo.name ~ ' - Demo Screenshot',
17+
},
18+
},
2019
} %}
2120

2221
{% block content %}
@@ -27,7 +26,7 @@
2726
<div class="text-center mt-md-0">
2827
<p class="eyebrows">
2928
<a href="{{ url('app_demos') }}">DEMOS</a> /
30-
<a href="{{ url('app_demos') }}">LiveComponent</a>
29+
<a href="{{ url('app_live_component') }}">Live Component</a>
3130
</p>
3231
<h1 class="text-center">{{ demo.name }}</h1>
3332
<div style="font-size: 1rem; line-height: 1.75rem;" class="mt-4 demo-introduction">

ux.symfony.com/templates/demos/live_memory/index.html.twig

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
{% extends 'base.html.twig' %}
2-
3-
{% set meta = {
4-
title: demo.name,
5-
title_suffix: ' - Symfony UX Demo',
6-
description: demo.description,
7-
canonical: url(demo.route),
8-
image: {
9-
url: absolute_url(asset(demo.screenshotFilename('1280x720'))),
10-
width: 1080,
11-
height: 720,
12-
},
13-
og: {
14-
title: demo.name ~ ' - Symfony UX Demo',
15-
description: demo.longDescription|striptags|u.truncate(200, '...')
16-
}
17-
} %}
1+
{% extends 'demos/live_demo.html.twig' %}
182

193
{% block stylesheets %}
204
<link rel="stylesheet" href="{{ asset('styles/demos/live-memory.min.css') }}"/>

ux.symfony.com/templates/ux_packages/package.html.twig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
{% extends 'base.html.twig' %}
22

33
{% set meta = {
4-
title: package.humanName,
4+
title: package.humanName ~ ' - ' ~ package.tagline,
55
description: package.description,
66
canonical: url(package.route),
7+
social: {
8+
title: package.tagline ~ ' - Symfony UX ' ~ package.humanName,
9+
description: package.description|striptags,
10+
image: {
11+
url: absolute_url(asset(package.imageFileName('1200x675'))),
12+
type: 'image/png',
13+
width: 1200,
14+
height: 675,
15+
alt: package.name ~ ' - Component Icon',
16+
},
17+
}
718
} %}
819

920
{% block header %}

0 commit comments

Comments
 (0)