Compare commits

..

1 Commits

Author SHA1 Message Date
Peter White 5d19ad7ba0 Open links in the tab their author chose 2026-11-18 04:25:52 +00:00
2 changed files with 15 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": minor
---
Open a link in the same or a new tab when its author chose one, instead of the site-wide external links setting.
@@ -40,7 +40,12 @@ export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
return (
<NotFoundRefHoverCard context={context}>
{fallback ? (
<InlineLinkAnchor href={fallback.href} contentRef={inline.data.ref} isExternal>
<InlineLinkAnchor
href={fallback.href}
contentRef={inline.data.ref}
target={inline.data.target}
isExternal
>
{inlinesElement}
</InlineLinkAnchor>
) : (
@@ -53,6 +58,7 @@ export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
<InlineLinkAnchor
href={resolved.href}
contentRef={resolved.resolvedRef ?? inline.data.ref}
target={inline.data.target}
isExternal={(resolved.resolvedRef ?? inline.data.ref).kind === 'url'}
>
{inlinesElement}
@@ -75,14 +81,16 @@ export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
function InlineLinkAnchor(props: {
href: string;
contentRef: ContentRef;
target: DocumentInlineLink['data']['target'];
isExternal?: boolean;
children: React.ReactNode;
}) {
const { href, isExternal, contentRef, children } = props;
const { href, isExternal, contentRef, target, children } = props;
const isMailto = href.startsWith('mailto:');
return (
<StyledLink
href={href}
target={target ? `_${target}` : undefined}
insights={{
type: 'link_click',
link: {