Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support code group container #2059

Merged
Merged
Show file tree
Hide file tree
Changes from 6 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
63 changes: 63 additions & 0 deletions docs/guide/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,66 @@ features:
</li>
</ul>
</Tree>

## CodeGroup <Badge>2.3.0+</Badge>

需要将多代码块合并成一个分组进行展示时,可以使用 CodeGroup 语法,例如:

```jsx
/**
* inline: true
*/
import SourceCode from 'dumi/theme/builtins/SourceCode';
const content = `
:::code-group

\`\`\`bash [npm]
npm install -D dumi
\`\`\`

\`\`\`bash [yarn]
yarn add -D dumi
\`\`\`

\`\`\`bash [pnpm]
pnpm add -D dumi
\`\`\`

\`\`\`ts [.dumirc.ts] {3}
import { defineConfig } from 'dumi';

export default defineConfig({
// ...
});
\`\`\`
:::
`.trim();

export default () => <SourceCode lang="markdown">{content}</SourceCode>;
```

将会被渲染为:

:::code-group

```bash [npm]
npm install -D dumi
```

```bash [yarn]
yarn add -D dumi
```

```bash [pnpm]
pnpm add -D dumi
```

```ts [.dumirc.ts] {3}
import { defineConfig } from 'dumi';

export default defineConfig({
// ...
});
```

:::
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"rc-tabs": "^12.10.0",
"rc-tooltip": "^6.1.3",
"rc-tree": "^5.7.9",
"rc-util": "^5.37.0",
"rc-util": "^5.38.0",
"react-copy-to-clipboard": "^5.1.0",
"react-error-boundary": "^4.0.10",
"react-intl": "^6.4.4",
Expand Down
Loading
Loading