mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-30 22:23:00 +00:00
feat(v2): open external links in new tab by default (#2780)
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.
This commit is contained in:
parent
05c3aa31f4
commit
70c201c24d
|
|
@ -84,7 +84,10 @@ function Link({isNavLink, ...props}: Props) {
|
|||
|
||||
return !targetLink || !isInternal || targetLink.startsWith('#') ? (
|
||||
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
||||
<a {...props} href={targetLink} />
|
||||
<a
|
||||
{...(isInternal ? props : {target: '_blank', ...props})}
|
||||
href={targetLink}
|
||||
/>
|
||||
) : (
|
||||
<LinkComponent
|
||||
{...props}
|
||||
|
|
|
|||
Loading…
Reference in New Issue