feat(plugin-docs): docs sidebar item link: support "autoAddBaseUrl" attribute #7949
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
See #7839 (comment)
We automatically add site baseUrl to links by default, including external links (those using the
pathname:///
protocol).But sometimes it doesn't make sense to apply that baseUrl. For example, if you have an i18n site but want to link to a local HTML file that is not localized, you don't want the
/locale/
baseUrl to be applied.We already have an
autoAddBaseUrl: false
escape hatch in props<Link>
, but it's not possible to use this prop through the sidebarNote:
autoAddBaseUrl
remains undocumented for now but we mention it in issues. Maybe it's not the good API we want to keep. Maybe we shouldautoAddBaseUrl
by default if the baseUrl is an i18n baseUrl 🤷♂️ For now I just expose the already existing hidden prop to provide the escape hatch, but we'll have to clean up the Docusaurus Link component at some point and expose a properly documented APIs.Test Plan
preview + dogfooding
Test links
https://deploy-preview-7949--docusaurus-2.netlify.app/tests/docs
(unfortunately, we don't deploy FR anymore to deploy previews => not really possible to test, but it works fine locally)