Skip to content
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(plugin-docs): docs sidebar item link: support "autoAddBaseUrl" attribute #7949

Merged
merged 1 commit into from
Aug 12, 2022

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Aug 12, 2022

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 sidebar

Note: autoAddBaseUrl remains undocumented for now but we mention it in issues. Maybe it's not the good API we want to keep. Maybe we should autoAddBaseUrl 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)

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Aug 12, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 12, 2022
@slorber slorber added the to backport This PR is planned to be backported to a stable version of Docusaurus label Aug 12, 2022
@netlify
Copy link

netlify bot commented Aug 12, 2022

[V2]

Name Link
🔨 Latest commit ca2579d
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/62f625840e8b2b0008968b45
😎 Deploy Preview https://deploy-preview-7949--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 79 🟢 98 🟢 100 🟢 100 🟠 80 Report
/docs/installation 🟠 74 🟢 100 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

Size Change: 0 B

Total Size: 812 kB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 52.5 kB
website/build/assets/css/styles.********.css 111 kB
website/build/assets/js/main.********.js 608 kB
website/build/index.html 40.7 kB

compressed-size-action

@slorber slorber merged commit de526e1 into main Aug 12, 2022
@slorber slorber deleted the slorber/sidebar-link-autoAddBaseUrl branch August 12, 2022 10:50
slorber added a commit that referenced this pull request Sep 1, 2022
@slorber slorber added backported This PR has been backported to a stable version of Docusaurus and removed to backport This PR is planned to be backported to a stable version of Docusaurus labels Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR has been backported to a stable version of Docusaurus CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants