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(v2): open external links in new tab by default #2780

Merged
merged 1 commit into from
May 21, 2020

Conversation

jknoxville
Copy link
Contributor

This changes the Link component to open external URLs in new tabs. This includes links in markdown in the form of [label](url), and also explicit use of the Link component.

You can override this behavior by passing target: '_self' as a prop when using Link.

Motivation

Docusaurus is already opinionated about doing this, for example the Navbar and
Footer do this already for external links. This is making it consistent across the entire site.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

cd website; yarn start;

  • In browser navigate to http://localhost:3000/docs/design-principles and click on "Minimal Surface Area" - Verify it opens in new tab. Do the same on other pages.
  • Verify anchor links continue to use the same tab.
  • Verify internal links continue to use the same tab.
  • Edit docs/design-principles.md to use Link instead of markdown syntax.
    • Verify it opens in a new tab.
  • Edit docs/design-principles.md to add the target="_self" attribute.
    • Verify it opens in the same tab.

Related PRs

None

Docusaurus is already opinionated about doing this, for example the navbar and
footer do this already.

This changes the Link component to do the same. This includes links in markdown
in the form of `[label](url)`.

You can override this behaviour by passing the target: '_self' prop.
@jknoxville jknoxville requested a review from yangshun as a code owner May 21, 2020 11:25
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 21, 2020
@yangshun yangshun added the pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. label May 21, 2020
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit c5db974

https://deploy-preview-2780--docusaurus-2.netlify.app

Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks John! We have to add docs to specify this behavior but I'll do that for you.

@yangshun yangshun changed the title feat: open external links in new tab by default feat(v2): open external links in new tab by default May 21, 2020
@yangshun yangshun merged commit 70c201c into facebook:master May 21, 2020
@lex111 lex111 added this to the v2.0.0-alpha.56 milestone May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: breaking change Existing sites may not build successfully in the new version. Description contains more details.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants