-
-
Notifications
You must be signed in to change notification settings - Fork 9k
feat(theme-classic): Add CodeBlockToken component for swizzling #11022
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
Conversation
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
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.
Can't this change be merged independently from other PRs if you removed all the unrelated things?
|
||
export default function CodeBlockToken(props: Props): ReactNode { | ||
// We omit the "line" information in the default rendering, | ||
// but its meant for devs who devs who Swizzle this component. |
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.
typo
8f90795
to
2acb5bd
Compare
Added, see #11017 (comment) |
Pre-flight checklist
Motivation
This PR is part of a series related to #11008 and it superceeds #11011 in the goal to splitup the work into more isolated refactoring/feature parts.
Note that this PR also includes the changes of previous steps and therefore the overall diff can be misleading. The best approach will be to review and merge every step individually and then rebase accordingly.
Intermediately the specific changes can be checked here: Danielku15/docusaurus@feature/codeblock-meta-3...Danielku15:docusaurus:feature/codeblock-meta-4
Step 1 (#11017): Splitup current parseLines logic (separation of concerns)
Step 2 (#11019): Parse metastring into metaOptions and use it across components.
Step 3 (#11021): Add parsing of any options specified in the metastring.
Step 4 (this PR): Add CodeBlockToken component to customize DOM of highlighted tokens.
Step 5: Pass
metaOptions
to whole codeblock component tree.The motivation of this part is to allow users to customize the rendering of the individual tokens rendered on the syntax highlighting. The component receives the props of the parent
Line
which already allows some degree of customization based on the data available.This change will unleash its full potential with Step 5 when we pass down
metaOptions
to all components.Test Plan
Automatic testing relies on existing integration tests.
Manual testing by checking
/docs/markdown-features/code-blocks
showed no impact of the change.If more testing is expected I'd need some guidance on how to typically such tests are written for Swizzled components.
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Code Blocks: https://deploy-preview-_____--docusaurus-2.netlify.app/docs/markdown-features/code-blocks/
Related issues/PRs