Skip to content

Commit d08ffb6

Browse files
authored
Automatic sidebar Beta badge addition based on wid in frontmatter (#28024)
* automatic sidebar badge based on content collection * more wid entries to product/feature pages * Add wid and remove message describing this PR from cloudflare-trace page * make parentheses the default for rendering of availability for the ProductAvailabilityText component
1 parent b05719e commit d08ffb6

10 files changed

Lines changed: 76 additions & 48 deletions

File tree

src/components/ProductAvailabilityText.astro

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Props {
77
parentheses?: string;
88
}
99
10-
const { product, parentheses = "false" } = Astro.props;
10+
const { product, parentheses = "true" } = Astro.props;
1111
1212
let entry = await getEntry("product-availability", product);
1313
let output = "";
@@ -25,8 +25,11 @@ else if (entry.data.availability.toUpperCase() === "GA") {
2525
}
2626
// show an availability value
2727
else {
28-
if (parentheses === "true") output = `(${entry.data.availability})`;
29-
else output = entry.data.availability;
28+
if (parentheses === "false") {
29+
output = entry.data.availability;
30+
} else {
31+
output = `(${entry.data.availability})`;
32+
}
3033
}
3134
---
3235

src/content/docs/dmarc-management/index.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
title: Cloudflare DMARC Management
33
pcx_content_type: overview
44
wid: dmarc-management
5-
sidebar:
6-
order: 1
7-
badge:
8-
text: Beta
95
head:
106
- tag: title
117
content: Overview

src/content/docs/pipelines/index.mdx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
---
22
title: Cloudflare Pipelines
3-
43
pcx_content_type: overview
54
wid: cloudflare-pipelines
6-
sidebar:
7-
order: 1
8-
badge:
9-
text: Beta
105
head:
116
- tag: title
127
content: Pipelines
Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
---
22
title: Cloudflare Privacy Gateway
33
pcx_content_type: overview
4-
sidebar:
5-
order: 1
6-
badge:
7-
text: Beta
4+
wid: privacy-gateway
85
head:
96
- tag: title
107
content: Overview
118
---
129

13-
import { Description, Feature, Plan } from "~/components"
10+
import { Description, Feature, Plan } from "~/components";
1411

1512
<Description>
1613

1714
Implements the Oblivious HTTP IETF standard to improve client privacy.
15+
1816
</Description>
1917

2018
<Plan type="enterprise" />
@@ -23,24 +21,36 @@ Implements the Oblivious HTTP IETF standard to improve client privacy.
2321

2422
OHTTP introduces a trusted third party between client and server, called a relay, whose purpose is to forward encrypted requests and responses between client and server. These messages are encrypted between client and server such that the relay learns nothing of the application data, beyond the length of the encrypted message and the server the client is interacting with.
2523

26-
***
24+
---
2725

2826
## Availability
2927

3028
Privacy Gateway is currently in closed beta – available to select privacy-oriented companies and partners. If you are interested, [contact us](https://www.cloudflare.com/lp/privacy-edge/).
3129

32-
***
30+
---
3331

3432
## Features
3533

36-
<Feature header="Get started" href="/privacy-gateway/get-started/" cta="Get started">
37-
Learn how to set up Privacy Gateway for your application.
34+
<Feature
35+
header="Get started"
36+
href="/privacy-gateway/get-started/"
37+
cta="Get started"
38+
>
39+
Learn how to set up Privacy Gateway for your application.
3840
</Feature>
3941

40-
<Feature header="Legal" href="/privacy-gateway/reference/legal/" cta="Learn more">
41-
Learn about the different parties and data shared in Privacy Gateway.
42+
<Feature
43+
header="Legal"
44+
href="/privacy-gateway/reference/legal/"
45+
cta="Learn more"
46+
>
47+
Learn about the different parties and data shared in Privacy Gateway.
4248
</Feature>
4349

44-
<Feature header="Metrics" href="/privacy-gateway/reference/metrics/" cta="Learn more">
45-
Learn about how to query Privacy Gateway metrics.
50+
<Feature
51+
header="Metrics"
52+
href="/privacy-gateway/reference/metrics/"
53+
cta="Learn more"
54+
>
55+
Learn about how to query Privacy Gateway metrics.
4656
</Feature>

src/content/docs/rules/cloud-connector/index.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ pcx_content_type: concept
44
wid: cloud-connector
55
sidebar:
66
order: 9
7-
group:
8-
badge:
9-
text: Beta
107
head:
118
- tag: title
12-
content: Cloud Connector (beta)
9+
content: Cloud Connector
1310
---
1411

15-
import { FeatureTable, Render } from "~/components";
12+
import { FeatureTable, ProductAvailabilityText, Render } from "~/components";
1613

17-
Cloud Connector (beta) allows you to route matching incoming traffic from your website to a public cloud provider that you define: [Cloudflare R2](/r2/) object storage or an external provider such as AWS, Google Cloud, and Azure. With Cloud Connector you can make Cloudflare the control center for your web traffic, including traffic served from public cloud providers, without having to configure additional rules.
14+
Cloud Connector <ProductAvailabilityText product="cloud-connector" /> allows you to route matching incoming traffic from your website to a public cloud provider that you define: [Cloudflare R2](/r2/) object storage or an external provider such as AWS, Google Cloud, and Azure. With Cloud Connector you can make Cloudflare the control center for your web traffic, including traffic served from public cloud providers, without having to configure additional rules.
1815

1916
<Render
2017
file="rules-requirements"

src/content/docs/rules/trace-request/how-to.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ pcx_content_type: reference
33
title: Use Cloudflare Trace
44
sidebar:
55
order: 2
6-
badge:
7-
text: Beta
86
head:
97
- tag: title
10-
content: How to - Cloudflare Trace (beta)
8+
content: How to - Cloudflare Trace
119
description: Learn how to use Cloudflare Trace in the dashboard and with the API.
1210
---
1311

src/content/docs/rules/trace-request/index.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
---
22
pcx_content_type: concept
33
title: Trace a request
4+
wid: cloudflare-trace
45
sidebar:
56
order: 14
6-
badge:
7-
text: Beta
8-
# TODO: set the badge text in the frontmatter from product-availability data
97
head:
108
- tag: title
119
content: Trace a request with Cloudflare Trace
@@ -15,7 +13,7 @@ import { DirectoryListing, Plan, ProductAvailabilityText } from "~/components";
1513

1614
<Plan type="all" />
1715

18-
Cloudflare Trace <ProductAvailabilityText product="cloudflare-trace" parentheses="true" /> follows an HTTP/S request through Cloudflare's reverse proxy to your origin. Use this tool to understand how different Cloudflare configurations interact with an HTTP/S request for one of your hostnames. If the hostname you are testing is not [proxied by Cloudflare](/dns/proxy-status/), Cloudflare Trace will still return all the configurations that Cloudflare would have applied to the request.
16+
Cloudflare Trace <ProductAvailabilityText product="cloudflare-trace" /> follows an HTTP/S request through Cloudflare's reverse proxy to your origin. Use this tool to understand how different Cloudflare configurations interact with an HTTP/S request for one of your hostnames. If the hostname you are testing is not [proxied by Cloudflare](/dns/proxy-status/), Cloudflare Trace will still return all the configurations that Cloudflare would have applied to the request.
1917

2018
You can define specific request properties to simulate different conditions for an HTTP/S request. Inactive rules configured in Cloudflare products will not be evaluated.
2119

src/content/docs/speed/optimization/content/fonts/index.mdx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
---
22
pcx_content_type: overview
3-
title: Cloudflare Fonts (beta)
3+
title: Cloudflare Fonts
4+
wid: fonts
45
sidebar:
56
order: 4
6-
badge:
7-
text: Beta
8-
97
---
108

11-
import { GlossaryTooltip, Render, DashButton } from "~/components"
9+
import { GlossaryTooltip, Render, DashButton } from "~/components";
1210

1311
Cloudflare Fonts is a feature designed for websites that use Google Fonts. It rewrites Google Fonts to be delivered from a website’s own origin, eliminating the need to rely on third-party font providers. Cloudflare Fonts is tailored to improve website performance and user privacy without the need for any code changes or self-hosting of fonts.
1412

@@ -49,8 +47,8 @@ To enable Cloudflare Fonts for your entire domain:
4947

5048
While Cloudflare Fonts offers powerful font optimization capabilities, it is important to be aware of its limitations:
5149

52-
* **Font transformation**: Currently, Cloudflare Fonts exclusively supports Google Fonts transformation.
53-
* **APO compatibility**: Cloudflare Fonts does not operate when [Automatic Platform Optimization](/automatic-platform-optimization/) (APO) is enabled. Cloudflare APO automatically optimizes Google Fonts in a similar way.
54-
* **CSS import**: Cloudflare Fonts is compatible only with the `<link>` setup for Google Fonts and does not support the CSS `@import` method.
55-
* **CSP headers**: Cloudflare Fonts does not modify <GlossaryTooltip term="content security policy (CSP)" link="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy">Content Security Policy (CSP)</GlossaryTooltip> headers. Certain CSP configurations may make Cloudflare Fonts stop working, such as restrictions on inline styles through [`style-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src), or restriction of fonts originating from the site's own origin via [`font-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/font-src).
56-
* **Fallback mechanism**: In cases where Cloudflare Fonts does not support a specific page, it will gracefully fallback to using Google Fonts.
50+
- **Font transformation**: Currently, Cloudflare Fonts exclusively supports Google Fonts transformation.
51+
- **APO compatibility**: Cloudflare Fonts does not operate when [Automatic Platform Optimization](/automatic-platform-optimization/) (APO) is enabled. Cloudflare APO automatically optimizes Google Fonts in a similar way.
52+
- **CSS import**: Cloudflare Fonts is compatible only with the `<link>` setup for Google Fonts and does not support the CSS `@import` method.
53+
- **CSP headers**: Cloudflare Fonts does not modify <GlossaryTooltip term="content security policy (CSP)" link="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy">Content Security Policy (CSP)</GlossaryTooltip> headers. Certain CSP configurations may make Cloudflare Fonts stop working, such as restrictions on inline styles through [`style-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src), or restriction of fonts originating from the site's own origin via [`font-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/font-src).
54+
- **Fallback mechanism**: In cases where Cloudflare Fonts does not support a specific page, it will gracefully fallback to using Google Fonts.

src/schemas/base.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,10 @@ export const baseSchema = ({ image }: SchemaContext) =>
135135
.describe(
136136
"Whether to show the FeedbackPrompt on the page, defaults to true",
137137
),
138+
wid: z
139+
.string()
140+
.optional()
141+
.describe(
142+
"What Id? Used as a generic identifier for external data sources",
143+
),
138144
});

src/util/sidebar.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ async function handleGroup(group: Group): Promise<SidebarEntry> {
214214

215215
if (frontmatter.sidebar.group?.badge) {
216216
group.badge = inferBadgeVariant(frontmatter.sidebar.group?.badge);
217+
} else if (frontmatter.wid) {
218+
const availabilityBadge = await productAvailabilityBadge(frontmatter.wid);
219+
if (availabilityBadge) {
220+
group.badge = availabilityBadge;
221+
}
217222
}
218223

219224
if (frontmatter.hideChildren) {
@@ -290,6 +295,11 @@ async function handleLink(link: Link): Promise<Link> {
290295

291296
if (link.badge) {
292297
link.badge = inferBadgeVariant(link.badge);
298+
} else if (frontmatter.wid) {
299+
const availabilityBadge = await productAvailabilityBadge(frontmatter.wid);
300+
if (availabilityBadge) {
301+
link.badge = availabilityBadge;
302+
}
293303
}
294304

295305
if (frontmatter.external_link && !frontmatter.sidebar.group?.hideIndex) {
@@ -309,6 +319,23 @@ async function handleLink(link: Link): Promise<Link> {
309319
return link;
310320
}
311321

322+
async function productAvailabilityBadge(
323+
wid: string,
324+
): Promise<Badge | undefined> {
325+
try {
326+
const availabilityEntry = await getEntry("product-availability", wid);
327+
if (
328+
availabilityEntry &&
329+
availabilityEntry.data.availability?.toLowerCase() === "beta"
330+
) {
331+
return { text: "Beta", variant: "caution" };
332+
}
333+
} catch (_error) {
334+
// If the entry doesn't exist in the collection, return undefined
335+
}
336+
return undefined;
337+
}
338+
312339
function inferBadgeVariant(badge: Badge) {
313340
if (!badge) return undefined;
314341

0 commit comments

Comments
 (0)