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
+42-25Lines changed: 42 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,40 +3,57 @@ 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
+
In addition to using basic Markdown, you can use our custom components to add additional formatting to the Cloudflare Docs, such as buttons, tabs, and collapsible sections.
9
9
10
-
## What is a component?
10
+
This page 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 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/).
15
13
16
-
## Using components
14
+
[Learn more about the Cloudflare Docs framework.](https://developers.cloudflare.com/style-guide/how-we-docs/our-site/#site-framework)
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.
16
+
## Add a component to a page
20
17
21
-
```mdx live
22
-
import { Details, RuleID } from"~/components"
18
+
To add a component to a page, you need to import it to the page and then add it:
<br/> {/* Line break to separate rendered components */}
22
+
```mdx
23
+
import {COMPONENT_NAME} from "~/components";
24
+
```
28
25
29
-
{/* Component with inside content */}
30
-
<Detailsheader="Open me!">
31
-
Hello, world!
32
-
</Details>
33
-
```
26
+
For example, if you were to add [the `DashButton` component](https://developers.cloudflare.com/style-guide/components/dash-button/) to the [Images getting started page](https://developers.cloudflare.com/images/get-started/), here is how the top of the Markdown of that page would look:
34
27
35
-
### Importing
28
+
```mdx
29
+
---
30
+
pcx_content_type: get-started
31
+
title: Getting started
32
+
sidebar:
33
+
order: 2
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
+
---
39
36
40
-
```mdx
41
-
import { Card, Render } from"~/components"
42
-
```
37
+
import {DashButton} from "~/components";
38
+
```
39
+
40
+
2. Add the component to the page by adding this Markdown wherever on the page you want the component to appear:
41
+
42
+
```mdx
43
+
<COMPONENT_NAMEPROP_NAME="PROP_VALUE" />
44
+
```
45
+
46
+
For example, if you were to add the `DashButton` component to some steps in the [Images getting started page](https://developers.cloudflare.com/images/get-started/), here is how the Markdown would look:
47
+
48
+
```mdx
49
+
1. In the Cloudflare dashboard, go to the **Transformations** page.
0 commit comments