代码块
<CodeBlock> 用属性控制标题、高亮、聚焦、行号与折叠的代码块。
大多数时候直接写围栏代码块即可,meta 语法(标题、行高亮、聚焦、最大行数……)见代码块。
用属性代替围栏 meta,适合属性较多或需要 links 的时候:
<CodeBlock title="client.ts" highlight="2" maxLines={0} links={{ "createClient": "/api-reference", "/get\\w+/": "/api-reference" }}>
```ts
import { createClient } from "@acme/sdk";
const client = createClient({ apiKey: process.env.ACME_KEY });
const me = await client.getMe();
```
</CodeBlock>import { createClient } from "@acme/sdk";
const client = createClient({ apiKey: process.env.ACME_KEY });
const me = await client.getMe();