Skip to content

Commit e65ad29

Browse files
committed
[Docs Site] Add area-specific OpenGraph images
1 parent 080c6d4 commit e65ad29

File tree

6 files changed

+59
-6
lines changed

6 files changed

+59
-6
lines changed

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"@cloudflare/vitest-pool-workers": "^0.5.32",
3939
"@cloudflare/workers-types": "^4.20241112.0",
4040
"@codingheads/sticky-header": "^1.0.2",
41-
"@iconify-json/material-symbols": "^1.2.8",
4241
"@iarna/toml": "^2.2.5",
42+
"@iconify-json/material-symbols": "^1.2.8",
4343
"@stoplight/json-schema-tree": "^4.0.0",
4444
"@types/dompurify": "^3.2.0",
4545
"@types/hast": "^3.0.4",
@@ -50,7 +50,7 @@
5050
"algoliasearch": "^5.15.0",
5151
"astro": "^4.16.12",
5252
"astro-breadcrumbs": "^3.2.2",
53-
"astro-icon": "^1.1.4",
53+
"astro-icon": "^1.1.2",
5454
"astro-live-code": "^0.0.4",
5555
"date-fns": "^4.1.0",
5656
"detype": "1.0.12",

public/core-services-preview.png

121 KB
Loading

public/dev-products-preview.png

60.2 KB
Loading

public/zt-preview.png

59.4 KB
Loading

src/components/overrides/Head.astro

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ if (currentSection) {
4444
content: "",
4545
});
4646
}
47+
4748
if (product.data.product.title) {
4849
const productName = product.data.product.title;
4950
Astro.props.entry.data.head.push({
@@ -63,7 +64,58 @@ if (currentSection) {
6364
content: "",
6465
});
6566
}
67+
6668
if (product.data.product.group) {
69+
const group = product.data.product.group.toLowerCase();
70+
71+
let ogImage = "https://developers.cloudflare.com/cf-twitter-card.png";
72+
const images: Record<string, string> = {
73+
"cloudflare essentials":
74+
"https://developers.cloudflare.com/core-services-preview.png",
75+
"cloudflare one": "https://developers.cloudflare.com/zt-preview.png",
76+
"developer platform":
77+
"https://developers.cloudflare.com/dev-products-preview.png",
78+
"network security":
79+
"https://developers.cloudflare.com/core-services-preview.png",
80+
"application performance":
81+
"https://developers.cloudflare.com/core-services-preview.png",
82+
"application security":
83+
"https://developers.cloudflare.com/core-services-preview.png",
84+
};
85+
86+
if (images[group]) {
87+
ogImage = images[group];
88+
}
89+
90+
const tags = [
91+
{
92+
tag: "meta",
93+
attrs: {
94+
name: "image",
95+
content: ogImage,
96+
},
97+
content: "",
98+
},
99+
{
100+
tag: "meta",
101+
attrs: {
102+
name: "og:image",
103+
content: ogImage,
104+
},
105+
content: "",
106+
},
107+
{
108+
tag: "meta",
109+
attrs: {
110+
name: "twitter:image",
111+
content: ogImage,
112+
},
113+
content: "",
114+
},
115+
] as const;
116+
117+
Astro.props.entry.data.head.push(...tags);
118+
67119
Astro.props.entry.data.head.push({
68120
tag: "meta",
69121
attrs: {

0 commit comments

Comments
 (0)