refactor(v2): introduce Logo component, remove useLogo hook #3745
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Since the
ThemedImage
component has been added, it would be nice to utilize it in the theme files. First thing that came to my mind was the site logo component. After studying a code for a bit, it came apparent that very similar code is used in the all places, so it can be quite easily extracted to the separate file.When I have finished the extraction, the next thing that picked up my attention was
useLogo
hook, which after the refactor seems redundant too (code can be moved to the newly createdLogo
component).This hook has not been documented yet on the website - https://v2.docusaurus.io/docs/theme-classic#hooks - (in opposition to the
theme-bootstrap
hook - https://v2.docusaurus.io/docs/theme-bootstrap/#uselogo), so I think that the removal shouldn't hurt any users. This change also makes code structure a bit simpler.In addition to the changes described above this refactor fixes a HTML check warning when user do not specified the
logo.alt
field in the navbar config (fallback totitle
, then just to"Logo"
string).Unfortunately the
sources
had to be extracted to the variable due to Rule of Hooks conditional call warnings.Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
Refactor has been tested on the Docusuaurs V2 website locally.
Related PRs