refactor(v2): add @theme-init alias to give access to initial components#2464
refactor(v2): add @theme-init alias to give access to initial components#2464
Conversation
|
Deploy preview for docusaurus-2 ready! Built with commit bdedcbc |
yangshun
left a comment
There was a problem hiding this comment.
Not really understanding this PR well. Why can't you use the @theme-original?
|
Because using While Do you see the difference? Do you understand now? And so we can use it for HOC. |
|
Any thoughts? Still not clear? It seems to me that this is a good way to get rid of code duplication in the live code block component, because it is annoying to duplicate changes every time. |
* feat: support comments for code highlighting * docs(v2): demonstrate highlighting with comments * chore: remove debugging console.log * fix: disable when language is undefined
|
Code highlighting via comments works as expected https://deploy-preview-2464--docusaurus-2.netlify.com/docs/next/markdown-features/#line-highlighting (in contrast to https://v2.docusaurus.io/docs/next/markdown-features/#line-highlighting) |
|
@yangshun I would really not like to close this PR, but I don't see you interested in it :( |
|
@yangshun can you accept this PR? Am I tired of updating it every time according to |
Motivation
I have long wanted to get rid of code duplication in code block components (one basic / one with live block) and, inspired by PR #2455, I realized how this can be achieved by creating a HOC and using the basic code block component as a wrapped component.
To do this, we need a new alias, with which we can get the "initial" component - from the theme itself, not overridden by any plugins.
In this PR, both the code for adding this alias and the refactoring of code block components are simultaneously presented in order to demonstrate it in action. If there is a green light, then I can split this PR into two separate ones.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Is an new test needed for this?
See this section on preview website, where basic code blocks and live editor are used.
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.)