You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/style-guide/components/index.mdx
+39-25Lines changed: 39 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,40 +3,54 @@ title: Components
3
3
sidebar:
4
4
order: 2
5
5
---
6
+
import { Details } from"~/components";
6
7
7
-
All of the components available to contributors writing content on Cloudflare's developer documentation
8
-
are documented in this section.
8
+
When you are [contributing to the Cloudflare Docs](/style-guide/contributions/), you can use our custom components to add additional formatting, such as buttons, tabs, and collapsible sections.
9
9
10
-
## What is a component?
10
+
This guide shows you the basics of importing and adding a component to a page. Refer to each component page in this Style Guide to learn the specific props and requirements for each.
11
11
12
-
[Astro components](https://docs.astro.build/en/basics/astro-components/) are re-usable HTML templates which
13
-
we use to reduce maintenance burden & duplicated code by returning frequently used layouts or snippets into
14
-
a component that can be imported and used across various pages.
12
+
Our components are based on [Astro components](https://docs.astro.build/en/basics/astro-components/) and are written in [MDX](https://docs.astro.build/en/guides/markdown-content/), an extended version of Markdown. [Learn more about the Cloudflare Docs framework](/style-guide/how-we-docs/our-site/#site-framework).
15
13
16
-
## Using components
14
+
## Add a component to a page
17
15
18
-
Content is authored in [MDX](https://docs.astro.build/en/guides/markdown-content/), which allows JavaScript
19
-
expressions and components to be used. They are like HTML elements, which can be self-closing.
<br/> {/* Line break to separate rendered components*/}
24
+
For example, if you were to add [the `DashButton` component](/style-guide/components/dash-button/) to the [Images getting started page](/images/get-started/), the top of the MDX file corresponding to that page would look like the following:
28
25
29
-
{/* Component with inside content */}
30
-
<Detailsheader="Open me!">
31
-
Hello, world!
32
-
</Details>
33
-
```
26
+
```mdx
27
+
---
28
+
pcx_content_type: get-started
29
+
title: Getting started
30
+
sidebar:
31
+
order: 2
34
32
35
-
### Importing
33
+
---
36
34
37
-
Components need to be imported to be made available inside a MDX file. All of our components are exported from
38
-
`"~/components"`, so they would be imported like this:
35
+
import {DashButton} from "~/components";
36
+
```
39
37
40
-
```mdx
41
-
import { Card, Render } from"~/components"
42
-
```
38
+
2. Add the component to the page by adding this text anywhere on the page you want the component to appear:
39
+
40
+
```mdx
41
+
<COMPONENT_NAMEPROP_NAME="PROP_VALUE" />
42
+
```
43
+
44
+
For example, if you were to add the `DashButton` component to some steps in the [Images getting started page](/images/get-started/), here is how the MDX file would look:
45
+
46
+
```mdx
47
+
1. In the Cloudflare dashboard, go to the **Transformations** page.
0 commit comments