-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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(v2): make code blocks more standalone #4315
Conversation
[V1] Deploy preview success Built with commit 669332b |
Size Change: +55 B (0%) Total Size: 532 kB
ℹ️ View Unchanged
|
Deploy preview for docusaurus-2 ready! Built with commit 669332b |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-4315--docusaurus-2.netlify.app/classic/ |
0fd2f09
to
711b78b
Compare
@@ -25,7 +23,10 @@ const MDXComponents: MDXComponentsObject = { | |||
return children; | |||
}, | |||
a: (props) => <Link {...props} />, | |||
pre: (props) => <div className={styles.mdxCodeBlock} {...props} />, | |||
pre: (props: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slorber here, as usual, I need your help with correct typing 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm I don't find a very good way to type this, but I don't think this is a big deal anyway
# Conflicts: # packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.js # website/src/pages/examples/markdownPageExample.md
LGTM! |
Motivation
Right now, when using
CodeBlock
component directly in documents, the font size will be larger than it should be.For example at https://v2.docusaurus.io/docs/next/i18n/crowdin#example-configuration
CodeBlock
I propose remove MDX wrapper around code blocks, and move its styles in
CodeBlock
component itself. This way, no matter how you use code blocks, they will look the same.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Compare results:
Current - https://v2.docusaurus.io/docs/next/i18n/crowdin#example-configuration
Preview - https://deploy-preview-4315--docusaurus-2.netlify.app/classic/docs/next/i18n/crowdin#example-configuration
To make sure that the new changes did not break anything, in the example page I added several code blocks created in different ways: https://deploy-preview-4315--docusaurus-2.netlify.app/classic/examples/markdownPageExample#code-block-test
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)