Skip to content

Commit 067c8e7

Browse files
authored
[Docs Site] Append product meta suffix to custom titles (#18445)
1 parent 9520778 commit 067c8e7

File tree

8 files changed

+31
-13
lines changed

8 files changed

+31
-13
lines changed

src/components/overrides/Head.astro

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,30 @@ if (currentSection) {
1414
1515
if (product) {
1616
if (product.data.meta.title) {
17-
const title = `${Astro.props.entry.data.title} | ${product.data.meta.title}`;
18-
Astro.props.entry.data.head.push({
19-
tag: "title",
20-
attrs: {},
21-
content: title,
22-
});
17+
const titleIdx = Astro.props.entry.data.head.findIndex(
18+
(x) => x.tag === "title",
19+
);
20+
21+
let title: string;
22+
23+
if (titleIdx !== -1) {
24+
const existingTitle = Astro.props.entry.data.head[titleIdx].content;
25+
title = `${existingTitle} · ${product.data.meta.title}`;
26+
27+
Astro.props.entry.data.head[titleIdx] = {
28+
tag: "title",
29+
attrs: {},
30+
content: title,
31+
};
32+
} else {
33+
title = `${Astro.props.entry.data.title} · ${product.data.meta.title}`;
34+
Astro.props.entry.data.head.push({
35+
tag: "title",
36+
attrs: {},
37+
content: title,
38+
});
39+
}
40+
2341
Astro.props.entry.data.head.push({
2442
tag: "meta",
2543
attrs: { property: "og:title", content: title },

src/content/docs/aegis/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 1
66
head:
77
- tag: title
8-
content: Overview | Cloudflare Aegis docs
8+
content: Overview
99
---
1010

1111
import { CardGrid, Description, GlossaryTooltip, LinkTitleCard, Plan, RelatedProduct } from "~/components"

src/content/docs/china-network/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 1
66
head:
77
- tag: title
8-
content: Overview | Cloudflare China Network
8+
content: Overview
99
---
1010

1111
import { Stream } from "~/components"

src/content/docs/page-shield/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 1
66
head:
77
- tag: title
8-
content: Overview | Cloudflare Page Shield
8+
content: Overview
99
description: Page Shield is a comprehensive client-side security and privacy
1010
solution that allows you to ensure the safety of your website visitors'
1111
browsing environment.

src/content/docs/rules/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 1
66
head:
77
- tag: title
8-
content: Overview | Cloudflare Rules
8+
content: Overview
99
---
1010

1111
import {

src/content/docs/ruleset-engine/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 2
66
head:
77
- tag: title
8-
content: Overview | Cloudflare Ruleset Engine
8+
content: Overview
99
---
1010

1111
import { LinkButton } from "~/components";

src/content/docs/ssl/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 1
66
head:
77
- tag: title
8-
content: Overview | Cloudflare SSL/TLS docs
8+
content: Overview
99
description: Cloudflare SSL/TLS offers free Universal SSL alongside advanced and enterprise features to meet your encryption and certificate management needs.
1010
---
1111

src/content/docs/waf/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 1
66
head:
77
- tag: title
8-
content: Overview | Cloudflare Web Application Firewall
8+
content: Overview
99
description: The Cloudflare Web Application Firewall (WAF) provides automatic
1010
protection from vulnerabilities and the flexibility to create custom rules.
1111
---

0 commit comments

Comments
 (0)