-
-
Notifications
You must be signed in to change notification settings - Fork 10k
Cleanup themes default/fallback values #3342
Copy link
Copy link
Closed
Labels
better engineeringNot a bug or feature requestNot a bug or feature requestbugAn error in the Docusaurus core causing instability or issues with its executionAn error in the Docusaurus core causing instability or issues with its executiondifficulty: starterIssues that are starter difficulty level, e.g. minimal tweaking with a clear test plan.Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan.good first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.If you are just getting started with Docusaurus, this issue should be a good place to begin.help wantedAsking for outside help and/or contributions to this particular issue or PR.Asking for outside help and/or contributions to this particular issue or PR.
Description
Metadata
Metadata
Assignees
Labels
better engineeringNot a bug or feature requestNot a bug or feature requestbugAn error in the Docusaurus core causing instability or issues with its executionAn error in the Docusaurus core causing instability or issues with its executiondifficulty: starterIssues that are starter difficulty level, e.g. minimal tweaking with a clear test plan.Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan.good first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.If you are just getting started with Docusaurus, this issue should be a good place to begin.help wantedAsking for outside help and/or contributions to this particular issue or PR.Asking for outside help and/or contributions to this particular issue or PR.
Type
Fields
No fields configured for issues without a type.
https://twitter.com/jaredpalmer/status/1298332787792109570
With the new theme validation/normalization, default values are applied ahead of time.
We should cleanup every piece of code that defines default/fallback values in the views unnecessarily because we don't want these fallback values to be duplicated everywhere, and it pollutes the code uselessly.
Here, we know that there's always a siteConfig, a themeConfig, and maybe an announcement bar, so it's not necessary to use
= {}each time.Also, we should strive to have proper TypeScript support. It is possible to have no announcementBar config, but I don't think we should destructure that config, falling back to {} just to ensure a runtime error.
In such case, the correct code should rather be:
This announcementBar case has been fixed with #3338
But there are many other places where such cleanup should be done.
I suggest we should also:
useThemeConfighook to reduce a bit boilerplate