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

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

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-classic/src/theme-classic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
22 changes: 22 additions & 0 deletions website/_dogfooding/_pages tests/code-block-tests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down