Skip to content

Commit 77caf4b

Browse files
authored
allow ReactNode for CodeBlock title
1 parent 7d36e2a commit 77caf4b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/docusaurus-theme-classic/src/theme-classic.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ declare module '@theme/CodeBlock' {
410410
readonly children: ReactNode;
411411
readonly className?: string;
412412
readonly metastring?: string;
413-
readonly title?: string;
413+
readonly title?: ReactNode;
414414
readonly language?: string;
415415
readonly showLineNumbers?: boolean | number;
416416
}

website/_dogfooding/_pages tests/code-block-tests.mdx

+12
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,18 @@ Multi-line text inside `pre` will turn into one-liner, but it's okay (https://gi
188188
<br />
189189
</CodeBlock>
190190

191+
### Code blocks with `ReactNode` in title
192+
193+
<CodeBlock
194+
className="language-yaml"
195+
title={<span className="badge badge--primary">YAML</span>}
196+
>
197+
link:{'\n'}
198+
{' '}title: front page{'\n'}
199+
{' '}path: /docs/{'\n'}
200+
</CodeBlock>
201+
202+
191203
## Code blocks with line numbering tests
192204

193205
```jsx

0 commit comments

Comments
 (0)