Skip to content

Commit b9b204a

Browse files
Merge branch 'production' of https://github.com/cloudflare/cloudflare-docs into production
2 parents 1deed6d + 6a59a43 commit b9b204a

File tree

50 files changed

+449
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+449
-192
lines changed

astro.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import starlightLinksValidator from "starlight-links-validator";
88
import icon from "astro-icon";
99
import sitemap from "@astrojs/sitemap";
1010
import react from "@astrojs/react";
11+
1112
import { readdir } from "fs/promises";
13+
import { fileURLToPath } from "url";
1214

1315
import rehypeTitleFigure from "rehype-title-figure";
1416
import rehypeMermaid from "./src/plugins/rehype/mermaid.ts";
1517
import rehypeAutolinkHeadings from "./src/plugins/rehype/autolink-headings.ts";
1618
import rehypeExternalLinks from "./src/plugins/rehype/external-links.ts";
1719
import rehypeHeadingSlugs from "./src/plugins/rehype/heading-slugs.ts";
18-
import { fileURLToPath } from "url";
1920

2021
async function autogenSections() {
2122
const sections = (

src/components/ModelCatalog.tsx

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from "react";
1+
import { useEffect, useState } from "react";
22
import ModelInfo from "./models/ModelInfo";
33
import ModelBadges from "./models/ModelBadges";
44
import { authorData } from "./models/data";
@@ -19,6 +19,22 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
1919
capabilities: [],
2020
});
2121

22+
useEffect(() => {
23+
const params = new URLSearchParams(window.location.search);
24+
25+
const search = params.get("search") ?? "";
26+
const authors = params.getAll("authors");
27+
const tasks = params.getAll("tasks");
28+
const capabilities = params.getAll("capabilities");
29+
30+
setFilters({
31+
search,
32+
authors,
33+
tasks,
34+
capabilities,
35+
});
36+
}, []);
37+
2238
const mapped = models.map((model) => ({
2339
model: {
2440
...model,
@@ -43,21 +59,21 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
4359
const authors = [...new Set(models.map((model) => model.name.split("/")[1]))];
4460
const capabilities = [
4561
...new Set(
46-
models
47-
.map((model) =>
48-
model.properties
49-
.flatMap(({ property_id, value }) => {
50-
if (property_id === "lora" && value === "true") {
51-
return "LoRA";
52-
}
62+
models.flatMap((model) =>
63+
model.properties
64+
.flatMap(({ property_id, value }) => {
65+
if (property_id === "lora" && value === "true") {
66+
return "LoRA";
67+
}
68+
69+
if (property_id === "function_calling" && value === "true") {
70+
return "Function calling";
71+
}
5372

54-
if (property_id === "function_calling" && value === "true") {
55-
return "Function calling";
56-
}
57-
})
58-
.filter((p) => Boolean(p)),
59-
)
60-
.flat(),
73+
return [];
74+
})
75+
.filter((p) => Boolean(p)),
76+
),
6177
),
6278
];
6379

@@ -102,7 +118,7 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
102118

103119
<div className="!mb-8 hidden md:block">
104120
<span className="text-sm font-bold uppercase text-gray-600 dark:text-gray-200">
105-
Model Types
121+
Tasks
106122
</span>
107123

108124
{tasks.map((task) => (
@@ -111,7 +127,8 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
111127
type="checkbox"
112128
className="mr-2"
113129
value={task}
114-
onClick={(e) => {
130+
checked={filters.tasks.includes(task)}
131+
onChange={(e) => {
115132
const target = e.target as HTMLInputElement;
116133

117134
if (target.checked) {
@@ -142,8 +159,9 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
142159
<input
143160
type="checkbox"
144161
value={capability}
162+
checked={filters.capabilities.includes(capability)}
145163
className="mr-2"
146-
onClick={(e) => {
164+
onChange={(e) => {
147165
const target = e.target as HTMLInputElement;
148166

149167
if (target.checked) {
@@ -177,7 +195,8 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
177195
type="checkbox"
178196
className="mr-2"
179197
value={author}
180-
onClick={(e) => {
198+
checked={filters.authors.includes(author)}
199+
onChange={(e) => {
181200
const target = e.target as HTMLInputElement;
182201

183202
if (target.checked) {

src/components/Render.astro

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,49 @@ const props = z.object({
1313
let { file, product, params } = props.parse(Astro.props);
1414
1515
if (!product) {
16-
product = Astro.params.slug?.split("/")[0];
17-
}
16+
const fromSlug = Astro.params.slug?.split("/")[0];
1817
19-
if (!product) {
20-
throw new Error(
21-
`[Render] Unable to infer which folder ${file} is in, please provide a "product" input with your "file" input.`,
22-
);
18+
if (!fromSlug) {
19+
throw new Error(
20+
`[Render] Unable to infer which folder ${file} is in, please provide a "product" input with your "file" input.`,
21+
);
22+
}
23+
24+
product = fromSlug;
2325
}
2426
25-
const partial = await getEntry("partials", `${product}/${file}`);
27+
const id = `${product}/${file}`;
28+
const partial = await getEntry("partials", id);
2629
2730
if (!partial) {
2831
throw new Error(
29-
`[Render] Couldn't find partial: ${file}. Included on ${Astro.params.slug}`,
32+
`[Render] Couldn't find "${id}" included on "${Astro.url.pathname}"`,
3033
);
3134
}
3235
36+
// We currently only enforce parameters if `params` is set in the frontmatter,
37+
// until we can migrate existing `inputParameters` frontmatter to `params`.
3338
if (partial.data.params) {
34-
const expected = partial.data.params;
35-
if (!params)
39+
const expected = partial.data.params.sort();
40+
const optional = expected.filter((p) => p.endsWith("?"));
41+
const received = Object.keys(params ?? {}).sort();
42+
43+
const maximum = expected.length;
44+
const minimum = maximum - optional.length;
45+
46+
if (
47+
received.length < minimum ||
48+
received.length > maximum ||
49+
expected.some((p: string) => {
50+
if (p.endsWith("?")) return false;
51+
52+
return !received.includes(p);
53+
})
54+
) {
3655
throw new Error(
37-
`${file} included on ${Astro.params.slug} expected parameters: ${expected}, got none`,
56+
`[Render] Expected parameters ${JSON.stringify(expected)} but received parameters ${JSON.stringify(received)} for "${file}" included on "${Astro.url.pathname}"`,
3857
);
58+
}
3959
}
4060
4161
const { Content } = await render(partial);

src/components/models/ModelBadges.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const ModelBadges = ({ model }: { model: WorkersAIModelsSchema }) => {
3333
<ul className="m-0 flex list-none items-center gap-2 p-0 text-xs">
3434
{badges.map((badge) => (
3535
<li key={badge.text}>
36-
<span className="sl-badge gray">{badge.text}</span>
36+
<span className="sl-badge default">{badge.text}</span>
3737
</li>
3838
))}
3939
</ul>

src/content.config.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z, defineCollection } from "astro:content";
1+
import { defineCollection } from "astro:content";
22

33
import { docsLoader, i18nLoader } from "@astrojs/starlight/loaders";
44
import { docsSchema, i18nSchema } from "@astrojs/starlight/schema";
@@ -20,6 +20,7 @@ import {
2020
warpReleasesSchema,
2121
releaseNotesSchema,
2222
fieldsSchema,
23+
partialsSchema,
2324
} from "~/schemas";
2425

2526
function contentLoader(name: string) {
@@ -36,10 +37,6 @@ function dataLoader(name: string) {
3637
});
3738
}
3839

39-
const partialSchema = z.object({
40-
params: z.string().array().optional(),
41-
});
42-
4340
export const collections = {
4441
docs: defineCollection({
4542
loader: docsLoader(),
@@ -61,7 +58,7 @@ export const collections = {
6158
}),
6259
partials: defineCollection({
6360
loader: contentLoader("partials"),
64-
schema: partialSchema,
61+
schema: partialsSchema,
6562
}),
6663
glossary: defineCollection({
6764
loader: dataLoader("glossary"),

src/content/docs/cloudflare-one/applications/casb/casb-integrations/atlassian-confluence.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { Render } from "~/components";
99
<Render
1010
file="casb/integration-description"
1111
params={{
12-
one: "Atlassian Confluence",
13-
two: "Atlassian Confluence Cloud account",
12+
integrationName: "Atlassian Confluence",
13+
integrationAccountType: "Atlassian Confluence Cloud account",
1414
}}
1515
/>
1616

@@ -43,7 +43,7 @@ These permissions follow the principle of least privilege to ensure that only th
4343

4444
<Render
4545
file="casb/security-findings"
46-
params={{ one: "Atlassian Confluence", two: "atlassian-confluence" }}
46+
params={{ integrationName: "Atlassian Confluence", slugRelativePath: "atlassian-confluence" }}
4747
/>
4848

4949
### Access security

src/content/docs/cloudflare-one/applications/casb/casb-integrations/atlassian-jira.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Render } from "~/components";
88

99
<Render
1010
file="casb/integration-description"
11-
params={{ one: "Atlassian Jira", two: "Atlassian Jira Cloud account" }}
11+
params={{ integrationName: "Atlassian Jira", integrationAccountType: "Atlassian Jira Cloud account" }}
1212
/>
1313

1414
:::note
@@ -35,7 +35,7 @@ These permissions follow the principle of least privilege to ensure that only th
3535

3636
<Render
3737
file="casb/security-findings"
38-
params={{ one: "Jira Cloud", two: "atlassian-jira" }}
38+
params={{ integrationName: "Jira Cloud", slugRelativePath: "atlassian-jira" }}
3939
/>
4040

4141
### Access security

src/content/docs/cloudflare-one/applications/casb/casb-integrations/aws-s3.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Render } from "~/components";
88

99
<Render
1010
file="casb/integration-description"
11-
params={{ one: "Amazon Web Services (AWS) S3", two: "AWS account" }}
11+
params={{ integrationName: "Amazon Web Services (AWS) S3", integrationAccountType: "AWS account" }}
1212
/>
1313

1414
## Integration prerequisites
@@ -65,7 +65,7 @@ For more information, refer to [Content findings](/cloudflare-one/applications/c
6565

6666
<Render
6767
file="casb/security-findings"
68-
params={{ one: "AWS S3", two: "aws-s3" }}
68+
params={{ integrationName: "AWS S3", slugRelativePath: "aws-s3" }}
6969
/>
7070

7171
### S3 Bucket security

src/content/docs/cloudflare-one/applications/casb/casb-integrations/bitbucket-cloud.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Render } from "~/components";
88

99
<Render
1010
file="casb/integration-description"
11-
params={{ one: "Bitbucket Cloud", two: "Bitbucket Cloud Cloud account" }}
11+
params={{ integrationName: "Bitbucket Cloud", integrationAccountType: "Bitbucket Cloud Cloud account" }}
1212
/>
1313

1414
:::note
@@ -46,7 +46,7 @@ These permissions follow the principle of least privilege to ensure that only th
4646

4747
<Render
4848
file="casb/security-findings"
49-
params={{ one: "Bitbucket Cloud", two: "bitbucket-cloud" }}
49+
params={{ integrationName: "Bitbucket Cloud", slugRelativePath: "bitbucket-cloud" }}
5050
/>
5151

5252
### Repository security

src/content/docs/cloudflare-one/applications/casb/casb-integrations/box.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Render } from "~/components";
88

99
<Render
1010
file="casb/integration-description"
11-
params={{ one: "Box", two: "Box account" }}
11+
params={{ integrationName: "Box", integrationAccountType: "Box account" }}
1212
/>
1313

1414
## Integration prerequisites
@@ -27,7 +27,7 @@ These permissions follow the principle of least privilege to ensure that only th
2727

2828
## Security findings
2929

30-
<Render file="casb/security-findings" params={{ one: "Box", two: "box" }} />
30+
<Render file="casb/security-findings" params={{ integrationName: "Box", slugRelativePath: "box" }} />
3131

3232
### File sharing
3333

0 commit comments

Comments
 (0)