Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/document/docs/en/guide/basic/use-mdx/_meta.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["link", "components"]
["link", "components", "container"]
161 changes: 161 additions & 0 deletions packages/document/docs/en/guide/basic/use-mdx/container.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Container

Containers are a great way to mark important information and provide hints to users.

:::tip
Rspress provides two styles of syntax, [`:::` syntax](#three-colon-syntax) and [GitHub Markdown Alerts syntax](#github-markdown-alerts-syntax).
:::

## `:::` Syntax \{#three-colon-syntax}

You can use the `:::` syntax to create custom containers and support custom titles. For example:

import { Tabs, Tab } from '@theme';

<Tabs>

<Tab label="Rendered Result">

:::note
This is a `block` of type `note`
:::

:::tip
This is a `block` of type `tip`
:::

:::info
This is a `block` of type `info`
:::

:::warning
This is a `block` of type `warning`
:::

:::danger
This is a `block` of type `danger`
:::

:::details
This is a `block` of type `details`
:::

:::tip Custom Title
This is a `block` of `Custom Title`
:::

:::tip\{title="Custom Title"}
This is a `block` of `Custom Title`
:::

</Tab>

<Tab label="Syntax">

```markdown
:::note
This is a `block` of type `note`
:::

:::tip
This is a `block` of type `tip`
:::

:::info
This is a `block` of type `info`
:::

:::warning
This is a `block` of type `warning`
:::

:::danger
This is a `block` of type `danger`
:::

:::details
This is a `block` of type `details`
:::

:::tip Custom Title
This is a `block` of `Custom Title`
:::

:::tip{title="Custom Title"}
This is a `block` of `Custom Title`
:::
```

</Tab>

</Tabs>

:::warning

We recommend using the syntax `:::tip Custom Title` directly.

When using the `:::` syntax in `.mdx` files and customizing headings with curly braces syntax, be aware of escaping.

```mdx
:::tip\{title="Custom Title"}

This is a `block` of `Custom Title`

:::
```

:::

## GitHub Markdown alerts syntax \{#github-markdown-alerts-syntax}

You can use [GitHub Markdown Alerts Syntax](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts) to create custom containers.

<Tabs>

<Tab label="Rendered Result">

> [!NOTE]
> This is a `block` of type `note`

> [!TIP]
> This is a `block` of type `tip`

> [!INFO]
> This is a `block` of type `info`

> [!WARNING]
> This is a `block` of type `warning`

> [!DANGER]
> This is a `block` of type `danger`

> [!DETAILS]
> This is a `block` of type `details`

</Tab>

<Tab label="Syntax">

```markdown
> [!NOTE]
> This is a `block` of type `note`

> [!TIP]
> This is a `block` of type `tip`

> [!INFO]
> This is a `block` of type `info`

> [!WARNING]
> This is a `block` of type `warning`

> [!DANGER]
> This is a `block` of type `danger`

> [!DETAILS]
> This is a `block` of type `details`
```

</Tab>

</Tabs>
122 changes: 0 additions & 122 deletions packages/document/docs/en/guide/basic/use-mdx/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,128 +84,6 @@ The previously defined properties will be passed to the component as `frontmatte
See [Front matter config](/api/config/config-frontmatter) for available front matter configurations.
:::

## Custom container

### `:::` Syntax

You can use the `:::` syntax to create custom containers and support custom titles. For example:

**Input:**

```markdown
:::note
This is a `block` of type `note`
:::

:::tip
This is a `block` of type `tip`
:::

:::info
This is a `block` of type `info`
:::

:::warning
This is a `block` of type `warning`
:::

:::danger
This is a `block` of type `danger`
:::

:::details
This is a `block` of type `details`
:::

:::tip Custom Title
This is a `block` of `Custom Title`
:::

:::tip{title="Custom Title"}
This is a `block` of `Custom Title`
:::
```

**Output:**

:::note
This is a `block` of type `note`
:::

:::tip
This is a `block` of type `tip`
:::

:::info
This is a `block` of type `info`
:::

:::warning
This is a `block` of type `warning`
:::

:::danger
This is a `block` of type `danger`
:::

:::details
This is a `block` of type `details`
:::

:::tip Custom Title
This is a `block` of `Custom Title`
:::

:::tip{title="Custom Title"}
This is a `block` of `Custom Title`
:::

### GitHub Markdown alerts syntax

You can also use [GitHub Markdown Alerts Syntax](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts) to create custom containers.

**Input:**

```markdown
> [!NOTE]
> This is a `block` of type `note`

> [!TIP]
> This is a `block` of type `tip`

> [!INFO]
> This is a `block` of type `info`

> [!WARNING]
> This is a `block` of type `warning`

> [!DANGER]
> This is a `block` of type `danger`

> [!DETAILS]
> This is a `block` of type `details`
```

**Output:**

> [!NOTE]
> This is a `block` of type `note`

> [!TIP]
> This is a `block` of type `tip`

> [!INFO]
> This is a `block` of type `info`

> [!WARNING]
> This is a `block` of type `warning`

> [!DANGER]
> This is a `block` of type `danger`

> [!DETAILS]
> This is a `block` of type `details`

## Code block

### Basic usage
Expand Down
2 changes: 1 addition & 1 deletion packages/document/docs/zh/guide/basic/use-mdx/_meta.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["link", "components"]
["link", "components", "container"]
Loading
Loading