fix(theme): CodeBlock should accept title of ReactNode type (#10999)

* allow ReactNode for CodeBlock title

* fix example
This commit is contained in:
Balthasar Hofer 2025-03-17 11:03:10 +01:00 committed by GitHub
parent 7d36e2a8ff
commit 579bb5ad37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View file

@ -410,7 +410,7 @@ declare module '@theme/CodeBlock' {
readonly children: ReactNode;
readonly className?: string;
readonly metastring?: string;
readonly title?: string;
readonly title?: ReactNode;
readonly language?: string;
readonly showLineNumbers?: boolean | number;
}

View file

@ -188,6 +188,28 @@ Multi-line text inside `pre` will turn into one-liner, but it's okay (https://gi
<br />
</CodeBlock>
## Code blocks with `ReactNode` in title
<CodeBlock
language="yaml"
title={
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}>
<span>
<code>ReactNode</code> title
</span>{' '}
<span className="badge badge--primary">YAML</span>
</div>
}>
{`link:
title: front page
path: /docs/`}
</CodeBlock>
## Code blocks with line numbering tests
```jsx