) => {
const isExternalWithOrigin = isExternalLink(href, window.location.origin);
- // Only trigger navigation context for internal links without modifier keys (i.e. open in new tab).
- if (!isExternal && !event.ctrlKey && !event.metaKey) {
+ // Only trigger navigation context for internal links in the same window without modifier keys (i.e. open in new tab).
+ if (!isExternal && target !== '_blank' && !event.ctrlKey && !event.metaKey) {
onNavigationClick(href);
}
diff --git a/packages/gitbook/src/components/primitives/Tooltip.tsx b/packages/gitbook/src/components/primitives/Tooltip.tsx
index 56ea447d9..2a9b8d463 100644
--- a/packages/gitbook/src/components/primitives/Tooltip.tsx
+++ b/packages/gitbook/src/components/primitives/Tooltip.tsx
@@ -4,6 +4,12 @@ import { tcls } from '@/lib/tailwind';
import * as RadixTooltip from '@radix-ui/react-tooltip';
import { useState } from 'react';
+export type TooltipProps = {
+ rootProps?: RadixTooltip.TooltipProps;
+ triggerProps?: RadixTooltip.TooltipTriggerProps;
+ contentProps?: RadixTooltip.TooltipContentProps;
+};
+
export function Tooltip(props: {
children: React.ReactNode;
label?: string | React.ReactNode;
diff --git a/packages/gitbook/src/lib/context.ts b/packages/gitbook/src/lib/context.ts
index f619b39a6..bfb5f0fb8 100644
--- a/packages/gitbook/src/lib/context.ts
+++ b/packages/gitbook/src/lib/context.ts
@@ -465,9 +465,7 @@ function parseVisibleSiteSectionsAndGroups(structure: SiteStructure, siteSection
siteSectionId
);
const visibleSectionsAndGroups = filterSectionsAndGroupsWithHiddenSiteSpaces(sectionsAndGroups);
- const current = section && !sectionHasOnlyHiddenSiteSpaces(section) ? section : null;
- assert(current, `couldn't find section "${siteSectionId}" in site structure`);
- return { list: visibleSectionsAndGroups, current } satisfies SiteSections;
+ return { list: visibleSectionsAndGroups, current: section } satisfies SiteSections;
}
function parseCurrentSection(structure: SiteStructure, siteSectionId: string) {
diff --git a/packages/gitbook/src/lib/embeddable.ts b/packages/gitbook/src/lib/embeddable.ts
index 339d806ad..84d743544 100644
--- a/packages/gitbook/src/lib/embeddable.ts
+++ b/packages/gitbook/src/lib/embeddable.ts
@@ -55,5 +55,16 @@ export function getEmbeddableLinker(linker: GitBookLinker): GitBookLinker {
spaceBasePath: joinPath(override.spaceBasePath, '~gitbook/embed/page'),
});
},
+
+ toLinkForContent(rawURL: string): string {
+ const result = linker.toLinkForContent(rawURL);
+ // If the link is not relative or already an embed, return it as is
+ if (result.includes('~gitbook/embed') || !result.startsWith('/')) {
+ return result;
+ }
+
+ // If the link is relative, assume it's a section link and append the embed path
+ return joinPath(result, '~gitbook/embed/page');
+ },
};
}
diff --git a/packages/gitbook/src/lib/references.tsx b/packages/gitbook/src/lib/references.tsx
index a0051ead9..f5245b689 100644
--- a/packages/gitbook/src/lib/references.tsx
+++ b/packages/gitbook/src/lib/references.tsx
@@ -129,7 +129,7 @@ export async function resolveContentRef(
const page = resolvePageResult?.page;
const ancestors =
resolvePageResult?.ancestors.map((ancestor) => ({
- label: ancestor.title,
+ label: ancestor.linkTitle || ancestor.title,
icon:
ancestor.emoji || ancestor.icon ? (
,
href,
});
@@ -177,7 +177,7 @@ export async function resolveContentRef(
parentPage && contentRef.page === parentPage.id && parentPage.type === 'group'
? parentPage
: page;
- text = pageOrGroup.title;
+ text = pageOrGroup.linkTitle || pageOrGroup.title;
emoji = isCurrentPage ? undefined : page.emoji;
icon =
;
}
diff --git a/packages/gitbook/src/middleware.ts b/packages/gitbook/src/middleware.ts
index 979276e22..f5b7f1113 100644
--- a/packages/gitbook/src/middleware.ts
+++ b/packages/gitbook/src/middleware.ts
@@ -612,6 +612,7 @@ function encodePathInSiteContent(rawPathname: string): {
}
switch (pathname) {
+ case '~gitbook/embed':
case '~gitbook/embed/assistant':
case '~gitbook/icon':
return { pathname };