Skip to content

Commit 9a62366

Browse files
KianNHdeadlypants1973
authored andcommitted
[Docs Site] Add CompatibilityFlag component (#19376)
1 parent f72511a commit 9a62366

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
import { Aside } from "@astrojs/starlight/components";
3+
import { reference, getEntry } from "astro:content";
4+
import { z } from "astro:schema";
5+
6+
const props = z.object({
7+
flag: reference("compatibility-flags"),
8+
});
9+
10+
const { flag } = await props.parseAsync(Astro.props);
11+
12+
const { data } = await getEntry("compatibility-flags", flag.slug);
13+
14+
const { enable_flag, enable_date } = data;
15+
---
16+
17+
<Aside>
18+
To use this feature,
19+
{
20+
enable_date && (
21+
<span>
22+
<a href="/workers/configuration/compatibility-dates/">
23+
define a compatibility date
24+
</a>{" "}
25+
of <code>{enable_date}</code> or higher, or
26+
</span>
27+
)
28+
} include <code>{enable_flag}</code> in your <a
29+
href={`/workers/configuration/compatibility-flags/#setting-compatibility-flags`}
30+
>compatibility flags</a
31+
>.
32+
</Aside>

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { Icon as AstroIcon } from "astro-icon/components";
77
// Custom components
88
export { default as AnchorHeading } from "./AnchorHeading.astro";
99
export { default as AvailableNotifications } from "./AvailableNotifications.astro";
10+
export { default as CompatibilityFlag } from "./CompatibilityFlag.astro";
1011
export { default as CompatibilityFlags } from "./CompatibilityFlags.astro";
1112
export { default as Description } from "./Description.astro";
1213
export { default as Details } from "./Details.astro";
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Compatibility flag
3+
---
4+
5+
This component will create an aside with the `enable_date` (if present) and the `enable_flag` of a given flag.
6+
7+
The flag must match the name of a file in the [`compatibility-flags` collection](https://github.com/cloudflare/cloudflare-docs/tree/production/src/content/compatibility-flags), without the file extension.
8+
9+
## Component
10+
11+
```mdx live
12+
import { CompatibilityFlag } from "~/components";
13+
14+
<CompatibilityFlag flag="global-navigator" />
15+
16+
<CompatibilityFlag flag="nodejs-compat" />
17+
```

0 commit comments

Comments
 (0)