-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
feat(v2): Add proof of concept for theme custom hooks #2714
Conversation
Deploy preview for docusaurus-2 ready! Built with commit f08789f |
Seems fine. @lex111 WDYT? Will this cause any issues? But I don't think they should be added to the |
Hi, I think there are multiple scenarios to consider, and this is part of a broader subject. Sharing code between themesWe might want to share code between the classic and bootstrap themes, and maybe other themes users would build. To me, this code is not necessarily only hooks, we might share components as well. For exemple, I think we should share a base MDXComponents between the 2 themes. So, for me Sharing code between plugin and its theme implementationIf you look at the DocPage component, there's a lot of similarities between the classic and bootstrap theme implementation. I think we need a way to abstract the shared parts directly in the plugin (that would contain some client-side code). As the classic theme is now implemented in TS, it would be nice to be able to share some types between the plugin and the theme page, for example the DocMetadata type that the plugin injects as props in the doc page. We could also share helper functions to help manipulate the injected data, which is not always in the convenient shape for all usecases |
I agree with you, when we started to build the Totally agree, I'll refactor this POC. |
Hey, I was keeping busy because of work. Could I work in this task? I don't know if someone already take it.. or if is in progress |
I'm thinking in split this in parts to facilitate the review and to help in case of something goes wrong
What do you think? |
Hey @fanny . What I suggest is to create a An example of an unintuitive bad candidate to me is this one: Despite being duplicated between classic/bootstrap themes, this code is "technical" and does not have anything UI related. In such case I think we should rather find a way to put back this code in docs content plugin directly, so that theme component api surface is simpler and more explicit (eventually find a way to add type safety between content plugin and theme implementation) |
closing in favor of |
Motivation
as suggested in #2636, when you're creating a new theme, can be interesting have the hooks functionalities to facilitate the components development.
Without this, if a user wants the logic of our sidebar, e.g., he'll need to copy-past the hook.
This is a Proof-of-concept, but i think that we should add a new lifecycle method in the theme,
getHooksPath
, it seems more consistent.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)
start the classic template
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.)