跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com

Markdown

最后更新 查看 MarkdownAgent 设置

该组件使用 marked ↗ 来渲染 CommonMark 和其他各种 Markdown 变体 ↗。

import { Markdown } from "~/components";

<Markdown text="**foo** <br/> [bar](/style-guide/build-the-page/components/markdown/)" />

在部分(partial)中使用变量的示例

如果您有一个变量需要以任何特殊方式进行格式化(例如,它需要是一个 URL、一个无序列表或其他内容),您可以在部分(partial)文件中使用 markdown 组件包装该变量。例如:

<Markdown text={props.foo} />

你需要将变量放在花括号中,并使用 text=,否则无法正常工作。

多行字符串

Markdown 组件使用 dedent ↗ 库来删除多行字符串中的缩进。

这是因为与 MDX ↗ 不同,CommonMark 规范 ↗将缩进的文本视为代码块。

import { Markdown } from "~/components";

<>
  <Markdown
  	text={`
    You need to purchase [Cloudflare WAN](https://www.cloudflare.com/magic-wan/) before you can purchase and use the Cloudflare One Appliance. The Cloudflare One Appliance can function as your primary edge device for your network, or be deployed in-line with existing network gear.

  	You also need to purchase a Cloudflare One Appliance before you can start configuring your settings in the Cloudflare dashboard. After buying a Cloudflare One Appliance, the device will be registered with your Cloudflare account and show up in your Cloudflare dashboard.

    Contact your account representative to learn more about purchasing options for the Cloudflare One Appliance device.
    `}
    inline={false}
  />
</>

这篇文档对您有帮助吗?