Skip to content

Commit fa17031

Browse files
authored
[Docs Site] Add area-specific OpenGraph images (#18610)
1 parent 958a3f4 commit fa17031

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

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)