Compare commits

..

10 Commits

96 changed files with 1169 additions and 725 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Track which Ask AI entry point opened the chat in ask view analytics.
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Keep the docs embed open when switching section, variant or language.
+6
View File
@@ -0,0 +1,6 @@
---
"@gitbook/embed": minor
"gitbook": patch
---
Add `defaultTab` and `defaultPage` options to the Docs Embed to choose where it opens. `defaultTab` opens the embed on the assistant, search or docs tab. `defaultPage` sets the page the docs tab opens on in place of the site's home page, and the embed opens on that page unless `defaultTab` says otherwise. Both work with the standalone script's `configure`, `frame.configure` and `<GitBookFrame>` props.
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Track server-side Insights events (markdown, llms.txt, RSS, ask) with the site's public URL instead of the proxy URL.
+6
View File
@@ -0,0 +1,6 @@
---
"@gitbook/react-openapi": patch
"gitbook": patch
---
Fix OpenAPI schemas that reference themselves through a nullable union rendering forever when expanded, which crashed PDF exports.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Export page subtrees as PDF in batches of 20 pages, with links to the previous and next batch, so large exports no longer crash.
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Fix previewed customization and theme overrides being lost when navigating between pages inside the site preview. The preview cookie was scoped to the site's canonical base path instead of the preview route it is actually served under, so the browser dropped it on the next in-preview navigation.
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Clarify the not-found page on sites with login-protected content: prompt anonymous visitors to log in, and tell logged-in visitors they may not have access.
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Let search buttons open search limited to the current space.
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Send the visitor country to resolvePublishedContentByUrl on dev, preview, staging and selected sites, using the forwarded `x-gitbook-country` header on revalidation requests.
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Read the production hostnames that receive the visitor country from the `GITBOOK_VISITOR_COUNTRY_HOSTNAMES` build-time env variable.
@@ -78,6 +78,11 @@ runs:
echo "GITBOOK_DISABLE_INSIGHTS=true" >> .vercel/.env.${{ inputs.environment }}.local
echo "--- .vercel/.env.${{ inputs.environment }}.local after inject ---"
cat .vercel/.env.${{ inputs.environment }}.local
- name: Inject visitor country hostnames
if: ${{ env.GITBOOK_VISITOR_COUNTRY_HOSTNAMES != '' }}
shell: bash
run: |
echo "GITBOOK_VISITOR_COUNTRY_HOSTNAMES=$GITBOOK_VISITOR_COUNTRY_HOSTNAMES" >> .vercel/.env.${{ inputs.environment }}.local
- name: Inject staging build env vars
if: ${{ inputs.environment == 'staging' }}
shell: bash
+4
View File
@@ -10,6 +10,8 @@ jobs:
environment:
name: 2v-production
url: ${{ steps.deploy.outputs.deployment-url }}
env:
GITBOOK_VISITOR_COUNTRY_HOSTNAMES: ${{ vars.GITBOOK_VISITOR_COUNTRY_HOSTNAMES }}
outputs:
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
steps:
@@ -31,6 +33,8 @@ jobs:
environment:
name: 2c-production
url: ${{ steps.deploy.outputs.deployment-url }}
env:
GITBOOK_VISITOR_COUNTRY_HOSTNAMES: ${{ vars.GITBOOK_VISITOR_COUNTRY_HOSTNAMES }}
outputs:
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
steps:
+2 -2
View File
@@ -355,7 +355,7 @@
},
"catalog": {
"@base-ui/react": "^1.7.0",
"@gitbook/api": "0.204.0",
"@gitbook/api": "0.205.0",
"@scalar/api-client-react": "^1.3.46",
"@tsconfig/node20": "^20.1.6",
"@tsconfig/strictest": "^2.0.6",
@@ -727,7 +727,7 @@
"@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@7.2.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "7.2.0" } }, "sha512-6639htZMjEkwskf3J+e6/iar+4cTNM9qhoWuRfj9F3eJD6r7iCzV1SWnQr2Mdv0QT0suuqU8BoJCZUyCtP9R4Q=="],
"@gitbook/api": ["@gitbook/api@0.204.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-SJCe0Ipyt+V5HZX4EZpFO8AHTOWIMwj2ljQTbcqgU7rVOAyCNDzILp8mRk9stbboSi1pv09+rDnZK1ZguPvFTw=="],
"@gitbook/api": ["@gitbook/api@0.205.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-jjkPAhPw6tja1N0ZPKqVsaV+opN8IS7yP1oZHHbcacZ477angPCo9YqiJJYWAl0tQ5OcKTuQbrsqhZSuwKM2Kw=="],
"@gitbook/browser-types": ["@gitbook/browser-types@workspace:packages/browser-types"],
+1 -1
View File
@@ -48,7 +48,7 @@
"@tsconfig/strictest": "^2.0.6",
"@tsconfig/node20": "^20.1.6",
"@base-ui/react": "^1.7.0",
"@gitbook/api": "0.204.0",
"@gitbook/api": "0.205.0",
"@scalar/api-client-react": "^1.3.46",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
+30
View File
@@ -54,6 +54,7 @@ GitBook('configure', {
icon: 'assistant' // 'assistant' | 'sparkle' | 'help' | 'book'
},
tabs: ['assistant', 'search', 'docs'],
defaultPage: '/getting-started',
actions: [
{
icon: 'circle-question',
@@ -107,6 +108,7 @@ frame.clearChat();
// Configure the embed (see Configuration section for all options)
frame.configure({
tabs: ['assistant', 'search', 'docs'],
defaultPage: '/getting-started',
actions: [
{
icon: 'circle-question',
@@ -142,6 +144,7 @@ import { GitBookProvider, GitBookFrame } from '@gitbook/embed/react';
unsignedClaims: { userId: '123' } // Optional: custom claims for dynamic expressions
}}
tabs={['assistant', 'search', 'docs']}
defaultPage="/getting-started"
greeting={{ title: 'Welcome!', subtitle: 'How can I help?' }}
assistantName="Support Assistant"
suggestions={['What is GitBook?', 'How do I get started?']}
@@ -249,6 +252,33 @@ Override which tabs are displayed. Defaults to your site's configuration.
tabs: ['assistant', 'search', 'docs']
```
### `defaultTab`
Available in: Standalone script, NPM package, React components
The tab the embed opens on. Without it, the embed opens on `defaultPage` if set, otherwise on the assistant (or the docs when the assistant isn't available). The tab must be one of the enabled `tabs`.
- **Type**: `'assistant' | 'search' | 'docs'`
```javascript
tabs: ['assistant', 'search', 'docs'],
defaultTab: 'search'
```
`defaultTab` and `defaultPage` apply when the embed first loads: the standalone widget keeps its place when it is closed and reopened. To move it later, use `navigateToPage` or `navigateToAssistant`.
### `defaultPage`
Available in: Standalone script, NPM package, React components
The page the docs tab opens on, in place of your site's home page. Accepts the same references as `navigateToPage`: the page's path within the site, an absolute path, or its full published URL. Unless `defaultTab` says otherwise, the embed opens on this page.
- **Type**: `string`
```javascript
defaultPage: '/getting-started/quickstart'
```
### `closeButton`
Available in: Standalone script, NPM package, React components
+6
View File
@@ -62,6 +62,12 @@ export type GitBookEmbeddableConfiguration = {
/** Tabs to display in the embed (if enabled on the site). */
tabs: ('assistant' | 'docs' | 'search')[];
/** Tab to open the embed on. */
defaultTab?: 'assistant' | 'docs' | 'search';
/** Page to open the docs tab on, instead of the site's home page. */
defaultPage?: string;
/** Additional buttons to be displayed in the header of the GitBook embed. */
actions: GitBookEmbeddableActionDefinition[];
@@ -27,6 +27,8 @@ export function GitBookFrame(props: GitBookFrameProps) {
suggestions = [],
tools = [],
tabs = ['assistant', 'search', 'docs'],
defaultTab,
defaultPage,
trademark = true,
closeButton = false,
assistantName,
@@ -50,6 +52,8 @@ export function GitBookFrame(props: GitBookFrameProps) {
useEffect(() => {
gitbookFrame?.configure({
tabs,
defaultTab,
defaultPage,
actions,
greeting,
suggestions,
@@ -65,6 +69,8 @@ export function GitBookFrame(props: GitBookFrameProps) {
suggestions,
tools,
tabs,
defaultTab,
defaultPage,
closeButton,
trademark,
assistantName,
+2
View File
@@ -95,6 +95,8 @@ const nextConfig = {
GITBOOK_BLOCK_SEARCH_INDEXATION: process.env.GITBOOK_BLOCK_SEARCH_INDEXATION,
GITBOOK_ALLOW_CUSTOMIZATION_OVERRIDE: process.env.GITBOOK_ALLOW_CUSTOMIZATION_OVERRIDE,
GITBOOK_DISABLE_INSIGHTS: process.env.GITBOOK_DISABLE_INSIGHTS,
GITBOOK_VISITOR_COUNTRY_HOSTNAMES: process.env.GITBOOK_VISITOR_COUNTRY_HOSTNAMES,
VERCEL_TARGET_ENV: process.env.VERCEL_TARGET_ENV,
// Next.js envs
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY,
+5 -4
View File
@@ -7,7 +7,7 @@ import type { CustomizationAIMode } from '@gitbook/api';
import type { GitBookAssistant } from '@gitbook/browser-types';
import { Icon, type IconName } from '@gitbook/icons';
import { useAIChatController, useAIChatState } from '.';
import { type AskAITrigger, useAIChatController, useAIChatState } from '.';
import { AIChatIcon, AISearchIcon, getAIChatName } from '../AIChat';
import { useIntegrationAssistants } from '../Integrations';
import { useSetSearchState } from '../Search/useSearch';
@@ -26,7 +26,8 @@ export type AIConfig = {
};
};
export type Assistant = Omit<GitBookAssistant, 'icon'> & {
export type Assistant = Omit<GitBookAssistant, 'icon' | 'open'> & {
open: (query?: string, trigger?: AskAITrigger) => void;
/**
* Unique identifier for the assistant. Generated automatically using Crypto.randomUUID().
* @example '123e4567-e89b-12d3-a456-426614174000'
@@ -102,8 +103,8 @@ export function useAI(): AIContext {
className="size-text-lg"
/>
),
open: (query?: string) => {
chatController.open();
open: (query?: string, trigger?: AskAITrigger) => {
chatController.open(trigger);
if (query) {
chatController.postMessage({ message: query });
}
@@ -11,6 +11,7 @@ import {
type AIStreamResponseToolCallPending,
type AIToolCallResult,
SiteInsightsDisplayContext,
type SiteInsightsEventAskView,
} from '@gitbook/api';
import { getInsightsSession, useTrackEvent } from '../Insights';
@@ -60,6 +61,8 @@ export type AIChatStatus =
| 'error'
| 'confirm';
export type AskAITrigger = NonNullable<SiteInsightsEventAskView['trigger']>;
export type AIChatState = {
/**
* If true, the chat is open.
@@ -160,7 +163,7 @@ type AIChatEventListener = (input?: Omit<AIChatEvent, 'type'>) => void;
export type AIChatController = {
/** Open the dialog */
open: () => void;
open: (trigger?: AskAITrigger) => void;
/** Close the dialog */
close: () => void;
/** Post a message to the session */
@@ -302,22 +305,28 @@ export function AIChatProvider(props: {
const eventsRef = React.useRef<Map<AIChatEvent['type'], AIChatEventListener[]>>(new Map());
// Open AI chat and sync with search state
const onOpen = React.useCallback(() => {
setIntercomLauncherHidden(true);
const onOpen = React.useCallback(
(trigger?: AskAITrigger) => {
setIntercomLauncherHidden(true);
if (!renderMessageOptions?.asEmbeddable) {
trackEvent({ type: 'ask_view', trigger });
}
const { initialQuery } = globalState.getState();
globalState.setState((state) => ({ ...state, opened: true }));
const { initialQuery } = globalState.getState();
globalState.setState((state) => ({ ...state, opened: true }));
// Update search state to show ask mode with first message or current ask value
setSearchState((prev) => ({
ask: prev?.ask ?? initialQuery ?? '',
query: prev?.query ?? null,
scope: prev?.scope ?? 'default',
open: false, // Close search popover when opening chat
}));
// Update search state to show ask mode with first message or current ask value
setSearchState((prev) => ({
ask: prev?.ask ?? initialQuery ?? '',
query: prev?.query ?? null,
scope: prev?.scope ?? 'default',
open: false, // Close search popover when opening chat
}));
notify(eventsRef.current.get('open'), {});
}, [setSearchState]);
notify(eventsRef.current.get('open'), {});
},
[setSearchState, trackEvent, renderMessageOptions?.asEmbeddable]
);
// Close AI chat and clear ask parameter
const onClose = React.useCallback(() => {
@@ -24,7 +24,6 @@ import {
EmbeddableFrameTitle,
} from '../Embeddable/EmbeddableFrame';
import { useIsMounted, useNow } from '../hooks';
import { useTrackEvent } from '../Insights';
import { Button } from '../primitives';
import { ScrollContainer } from '../primitives/ScrollContainer';
import { SideSheet } from '../primitives/SideSheet';
@@ -68,16 +67,6 @@ export function AIChat() {
}
);
// Track the view of the AI chat
const trackEvent = useTrackEvent();
React.useEffect(() => {
if (chat.opened) {
trackEvent({
type: 'ask_view',
});
}
}, [chat.opened, trackEvent]);
return (
<SideSheet
side="right"
@@ -39,7 +39,7 @@ export function AIChatButton(props: {
</div>
}
aria-label={tString(language, 'ai_chat_ask', assistant.label)}
onClick={() => assistant.open()}
onClick={() => assistant.open(undefined, 'site')}
>
{showLabel ? t(language, 'ask') : null}
</Button>
@@ -33,7 +33,7 @@ export function AskAIParagraphButton(props: { content: string; className?: Class
id: `text-${fnv1a(text, { size: 32 })}`,
content: text,
});
chatController.open();
chatController.open('hover');
chatController.setDraft(tString(language, 'ai_chat_paragraph_draft'));
chatController.focus();
};
@@ -84,7 +84,7 @@ export function AskAITextSelection() {
id: `text-${fnv1a(content, { size: 32 })}`,
content,
});
chatController.open();
chatController.open('selection');
chatController.focus();
clear();
};
@@ -13,9 +13,14 @@ const INPUT_SIZE_MAP: Record<NonNullable<ButtonProps['size']>, 'small' | 'medium
};
export function InlineActionButton(
props: { action: 'ask' | 'search'; query?: string } & { buttonProps: ButtonProps } // TODO: Type this properly: Pick<api.DocumentInlineButton, 'action' | 'query'> & { buttonProps: ButtonProps }
props: {
action: 'ask' | 'search';
query?: string;
/** Where a search runs: the whole site, or only the space the visitor is reading. */
scope?: 'site' | 'space';
} & { buttonProps: ButtonProps } // TODO: Type this properly: Pick<api.DocumentInlineButton, 'action' | 'query'> & { buttonProps: ButtonProps }
) {
const { action, query, buttonProps } = props;
const { action, query, scope, buttonProps } = props;
const { assistants } = useAI();
const chatState = useAIChatState();
@@ -29,7 +34,7 @@ export function InlineActionButton(
setSearchState((prev) => ({
...prev,
ask: null,
scope: 'default',
scope: scope === 'space' ? 'current' : 'default',
query: value ?? query,
open: true,
}));
@@ -47,6 +47,11 @@ export function InlineButton(props: InlineProps<api.DocumentInlineButton>) {
<InlineActionButton
action={inline.data.action.action}
query={inline.data.action.query ?? ''}
scope={
inline.data.action.action === 'search'
? inline.data.action.scope
: undefined
}
buttonProps={buttonProps}
/>
);
@@ -61,9 +61,7 @@ export function EmbeddableAIChat(props: EmbeddableAIChatProps) {
}
trackEvent(
{
type: 'ask_view',
},
{ type: 'ask_view', trigger: 'embed' },
{
pageId: null,
displayContext: api.SiteInsightsDisplayContext.Embed,
@@ -97,6 +97,7 @@ export async function EmbeddableDocsPage(
) ?? context.siteSpace
}
siteSpaces={variants.translations}
asEmbeddable
className="my-1.5 ml-2 self-start"
/>
) : null}
@@ -125,6 +126,7 @@ export async function EmbeddableDocsPage(
) ?? context.siteSpace
}
siteSpaces={variants.translations}
asEmbeddable
className="max-md:[&_.button-content]:block"
/>
) : null
@@ -137,6 +139,7 @@ export async function EmbeddableDocsPage(
context={context}
siteSpace={context.siteSpace}
siteSpaces={variants.generic}
asEmbeddable
className="w-full px-3"
/>
) : null}
@@ -9,6 +9,7 @@ import type { GitBookEmbeddableConfiguration, ParentToFrameMessage } from '@gitb
import { integrationsAssistantTools } from '../Integrations';
import { Button, LinkContext, type LinkContextType } from '../primitives';
import { getChannel } from './channel';
import { DEFAULT_EMBEDDABLE_TABS, getEmbeddableLandingTab } from './getEmbeddableLandingTab';
import { resolveEmbedPageLink } from './server-actions';
import { useAI, useAIChatController } from '@/components/AI';
import { isAIChatEnabled } from '@/components/utils/isAIChatEnabled';
@@ -23,6 +24,17 @@ const embeddableConfiguration = createStore<GitBookEmbeddableConfiguration>(() =
trademark: true,
}));
const docsHome = createStore<{ reference?: string; href?: string }>(() => ({}));
// Module-level so it survives the layout remounting on a cross-space navigation.
let landed = false;
function resolvePageHref(pagePath: string, baseURL: string): Promise<string> {
return resolveEmbedPageLink(pagePath)
.then((resolved) => ('href' in resolved ? resolved.href : `${baseURL}/page/${pagePath}`))
.catch(() => `${baseURL}/page/${pagePath}`);
}
// oxlint-disable-next-line typescript/no-explicit-any
function log(...data: any[]) {
// oxlint-disable-next-line no-console
@@ -66,6 +78,15 @@ export function EmbeddableIframeAPI(props: { baseURL: string }) {
const { baseURL, router, chatController } = refs.current;
const message = payload as ParentToFrameMessage;
const navigate = (href: Promise<string>) => {
const token = ++navToken.current;
href.then((href) => {
if (navToken.current === token) {
refs.current.router.push(href);
}
});
};
log('[gitbook] received message', message);
switch (message.type) {
@@ -83,29 +104,43 @@ export function EmbeddableIframeAPI(props: { baseURL: string }) {
break;
}
case 'configure': {
embeddableConfiguration.setState(message.settings);
const { settings } = message;
embeddableConfiguration.setState(settings);
integrationsAssistantTools.setState({
tools: message.settings.tools,
tools: settings.tools,
});
const defaultPage =
typeof settings.defaultPage === 'string' && settings.defaultPage
? settings.defaultPage
: undefined;
let docsHomeHref: Promise<string> | undefined;
if (defaultPage !== docsHome.getState().reference) {
docsHome.setState({ reference: defaultPage, href: undefined });
if (defaultPage) {
docsHomeHref = resolvePageHref(defaultPage, baseURL);
docsHomeHref.then((href) => {
if (docsHome.getState().reference === defaultPage) {
docsHome.setState({ href });
}
});
}
}
if (!landed) {
landed = true;
const tab = getEmbeddableLandingTab(settings);
if (tab === 'docs') {
navigate(docsHomeHref ?? Promise.resolve(`${baseURL}/page/`));
} else if (tab) {
navToken.current++;
router.push(`${baseURL}/${tab}`);
}
}
break;
}
case 'navigateToPage': {
// Resolve the target server-side: on a multi-space site the page may
// live in another space/section, whose base must go before
// `~gitbook/embed/page`. Fall back to a same-space push on failure.
const { pagePath } = message;
const token = ++navToken.current;
// Ignore the result if a later navigation has since superseded this one.
const push = (href: string) => {
if (navToken.current === token) {
router.push(href);
}
};
resolveEmbedPageLink(pagePath)
.then((resolved) =>
push('href' in resolved ? resolved.href : `${baseURL}/page/${pagePath}`)
)
.catch(() => push(`${baseURL}/page/${pagePath}`));
navigate(resolvePageHref(message.pagePath, baseURL));
break;
}
case 'navigateToAssistant': {
@@ -132,7 +167,7 @@ export function useEmbeddableConfiguration<T = GitBookEmbeddableConfiguration>(
export function useEmbeddableTabs() {
const configuredTabs = useEmbeddableConfiguration((state) => state.tabs);
return configuredTabs.length > 0 ? configuredTabs : ['assistant', 'search', 'docs'];
return configuredTabs.length > 0 ? configuredTabs : DEFAULT_EMBEDDABLE_TABS;
}
export function useEmbeddableLinkContext() {
@@ -200,6 +235,7 @@ export function EmbeddableIframeTabs(props: {
const { ref, active = 'assistant', baseURL, siteTitle, onNavigate } = props;
const actions = useEmbeddableConfiguration((state) => state.actions);
const tabs = useEmbeddableTabs();
const docsHomeHref = useStore(docsHome, (state) => state.href);
const { assistants, config } = useAI();
const language = useLanguage();
@@ -228,7 +264,7 @@ export function EmbeddableIframeTabs(props: {
key: 'docs',
label: siteTitle,
icon: 'book-open',
href: `${baseURL}/page/`,
href: docsHomeHref ?? `${baseURL}/page/`,
}
: null,
].filter((tab) => tab !== null);
@@ -0,0 +1,39 @@
import { describe, expect, it } from 'bun:test';
import { getEmbeddableLandingTab } from './getEmbeddableLandingTab';
describe('getEmbeddableLandingTab', () => {
it('keeps the embed default when nothing is configured', () => {
expect(getEmbeddableLandingTab({})).toBeNull();
expect(getEmbeddableLandingTab({ tabs: ['docs', 'search'] })).toBeNull();
});
it('opens on the configured tab', () => {
expect(getEmbeddableLandingTab({ defaultTab: 'search' })).toBe('search');
expect(
getEmbeddableLandingTab({ tabs: ['assistant', 'search', 'docs'], defaultTab: 'search' })
).toBe('search');
});
it('opens on the docs when only a default page is set', () => {
expect(getEmbeddableLandingTab({ defaultPage: 'getting-started' })).toBe('docs');
});
it('prefers the configured tab over the default page', () => {
expect(
getEmbeddableLandingTab({ defaultTab: 'assistant', defaultPage: 'getting-started' })
).toBe('assistant');
});
it('ignores a tab that is not enabled', () => {
expect(getEmbeddableLandingTab({ tabs: ['assistant'], defaultTab: 'search' })).toBeNull();
expect(
getEmbeddableLandingTab({ tabs: ['assistant', 'search'], defaultPage: 'quickstart' })
).toBeNull();
});
it('ignores an unknown tab', () => {
// @ts-expect-error - the parent window is plain JS and can send anything.
expect(getEmbeddableLandingTab({ defaultTab: 'settings' })).toBeNull();
});
});
@@ -0,0 +1,17 @@
import type { GitBookEmbeddableConfiguration } from '@gitbook/embed';
export type EmbeddableTab = GitBookEmbeddableConfiguration['tabs'][number];
export const DEFAULT_EMBEDDABLE_TABS: EmbeddableTab[] = ['assistant', 'search', 'docs'];
export function getEmbeddableLandingTab(
settings: Partial<Pick<GitBookEmbeddableConfiguration, 'tabs' | 'defaultTab' | 'defaultPage'>>
): EmbeddableTab | null {
const tab = settings.defaultTab ?? (settings.defaultPage ? 'docs' : undefined);
if (!tab || !DEFAULT_EMBEDDABLE_TABS.includes(tab)) {
return null;
}
const tabs = settings.tabs?.length ? settings.tabs : DEFAULT_EMBEDDABLE_TABS;
return tabs.includes(tab) ? tab : null;
}
@@ -2,9 +2,10 @@ import type { SiteSpace } from '@gitbook/api';
import type { IconName } from '@gitbook/icons';
import type { ButtonProps } from '../primitives';
import { getTargetURLForSiteSpace } from '../SiteSections/encodeClientSiteSections';
import { SpacesDropdownClient } from './SpacesDropdownClient';
import type { GitBookSiteContext } from '@/lib/context';
import { getLocalizedTitle, getSiteSpaceURL } from '@/lib/sites';
import { getLocalizedTitle } from '@/lib/sites';
import { tcls } from '@/lib/tailwind';
// Memoized regex for checking if a string starts with an emoji
@@ -20,9 +21,18 @@ export function SpacesDropdown(
siteSpace: SiteSpace;
siteSpaces: SiteSpace[];
className?: string;
/** Keep the links inside the embed rather than sending readers to the full site. */
asEmbeddable?: boolean;
} & ButtonProps
) {
const { context, siteSpace, siteSpaces, className, ...buttonProps } = props;
const {
context,
siteSpace,
siteSpaces,
className,
asEmbeddable = false,
...buttonProps
} = props;
const currentLanguage = context.locale;
const dropdownClassName = tcls(
@@ -33,7 +43,7 @@ export function SpacesDropdown(
const slimSpaces = siteSpaces.map((siteSp) => ({
id: siteSp.id,
title: getLocalizedTitle(siteSp, currentLanguage),
url: getSiteSpaceURL(context, siteSp),
url: getTargetURLForSiteSpace(context, siteSp, asEmbeddable),
isActive: siteSp.id === siteSpace.id,
spaceId: siteSp.space.id,
}));
@@ -57,9 +67,10 @@ export function TranslationsDropdown(
siteSpace: SiteSpace;
siteSpaces: SiteSpace[];
className?: string;
asEmbeddable?: boolean;
} & ButtonProps
) {
const { context, siteSpace, siteSpaces, className, ...buttonProps } = props;
const { context, siteSpace, siteSpaces, className, asEmbeddable, ...buttonProps } = props;
const title = getLocalizedTitle(siteSpace, context.locale);
const hasEmojiPrefix = startsWithEmoji(title);
@@ -70,6 +81,7 @@ export function TranslationsDropdown(
context={context}
siteSpace={siteSpace}
siteSpaces={siteSpaces}
asEmbeddable={asEmbeddable}
variant="blank"
className={tcls(
'bg-transparent lg:max-w-64 max-md:[&_.button-content]:hidden',
@@ -3,13 +3,6 @@ import { describe, expect, it } from 'bun:test';
import { RevisionPageType } from '@gitbook/api';
import { createPDFLinker } from './linker';
import { selectPages } from './selectPages';
import {
PDF_DEFAULT_LIMIT,
PDF_SUBTREE_DEFAULT_LIMIT,
getPDFSearchParams,
getPDFURLSearchParams,
} from './urls';
import { createLinker, linkerWithAbsoluteURLs } from '@/lib/links';
import { getLinkerForSiteSpace } from '@/lib/sites';
@@ -22,10 +15,6 @@ function createDocumentPage(id: string, path: string) {
} as any;
}
function createDocumentPageWithChildren(id: string, children: any[]) {
return { ...createDocumentPage(id, id), pages: children };
}
function createGroupPage(id: string, path: string) {
return {
id,
@@ -219,183 +208,3 @@ describe('createPDFLinker', () => {
).toBe('https://open-2v.gitbook.com/~space/HJ1ltuWFvsArFWtevnRn~gitbook/pdf/respond');
});
});
describe('createPDFLinker with batches', () => {
const baseLinker = createLinker({
host: 'open-2v.gitbook.com',
siteBasePath: '/~space/HJ1ltuWFvsArFWtevnRn',
spaceBasePath: '/~space/HJ1ltuWFvsArFWtevnRn',
});
const getBatchURL = (page: { id: string }) =>
page.id === 'other-batch'
? 'https://open-2v.gitbook.com/~gitbook/pdf?offset=20'
: undefined;
it('prefers the published URL for documents exported in another batch', () => {
const linker = createPDFLinker(
baseLinker,
[{ page: createDocumentPage('included', '') }],
createPublishedLinker(),
{ getBatchURL }
);
expect(
linker.toPathForPage({
pages: [
createDocumentPage('included', ''),
createDocumentPage('other-batch', 'respond'),
],
page: createDocumentPage('other-batch', 'respond'),
})
).toBe('https://docs.vectra.ai/deployment/respond');
});
it('links to the batch containing a page when there is no published URL', () => {
const linker = createPDFLinker(
baseLinker,
[{ page: createDocumentPage('included', '') }],
undefined,
{ getBatchURL }
);
expect(
linker.toPathForPage({
pages: [createDocumentPage('other-batch', 'respond')],
page: createDocumentPage('other-batch', 'respond'),
anchor: 'faq',
})
).toBe('https://open-2v.gitbook.com/~gitbook/pdf?offset=20#page-other-batch-faq');
});
it('links group pages to the batch containing them', () => {
const linker = createPDFLinker(
baseLinker,
[{ page: createDocumentPage('included', '') }],
createPublishedLinker(),
{ getBatchURL }
);
expect(
linker.toPathForPage({
pages: [createGroupPage('other-batch', 'group')],
page: createGroupPage('other-batch', 'group'),
})
).toBe('https://open-2v.gitbook.com/~gitbook/pdf?offset=20#page-other-batch');
});
});
describe('getPDFSearchParams', () => {
it('defaults to a small batch for subtree exports', () => {
expect(getPDFSearchParams(new URLSearchParams('page=abc&only=yes'))).toEqual({
page: 'abc',
only: true,
limit: PDF_SUBTREE_DEFAULT_LIMIT,
offset: 0,
});
expect(PDF_SUBTREE_DEFAULT_LIMIT).toBe(20);
});
it('keeps the larger default for whole-space and single-page exports', () => {
expect(getPDFSearchParams(new URLSearchParams('')).limit).toBe(PDF_DEFAULT_LIMIT);
expect(getPDFSearchParams(new URLSearchParams('page=abc')).limit).toBe(PDF_DEFAULT_LIMIT);
expect(PDF_DEFAULT_LIMIT).toBe(100);
});
it('parses an explicit limit and offset', () => {
const params = getPDFSearchParams(
new URLSearchParams('page=abc&only=yes&limit=5&offset=10')
);
expect(params.limit).toBe(5);
expect(params.offset).toBe(10);
});
it('ignores invalid limit and offset values', () => {
const params = getPDFSearchParams(
new URLSearchParams('page=abc&only=yes&limit=nope&offset=-3')
);
expect(params.limit).toBe(PDF_SUBTREE_DEFAULT_LIMIT);
expect(params.offset).toBe(0);
expect(getPDFSearchParams(new URLSearchParams('limit=0&offset=1.5'))).toMatchObject({
limit: PDF_DEFAULT_LIMIT,
offset: 0,
});
});
it('round-trips through getPDFURLSearchParams', () => {
const params = { page: 'abc', only: true, limit: 20, offset: 40, back: 'false' };
expect(getPDFSearchParams(getPDFURLSearchParams(params))).toEqual(params);
});
it('omits offset and limit when not set', () => {
expect(getPDFURLSearchParams({ page: 'abc', only: true }).toString()).toBe(
'page=abc&only=yes'
);
});
});
describe('selectPages', () => {
const children = Array.from({ length: 45 }, (_, index) =>
createDocumentPage(`child-${index}`, `child-${index}`)
);
const rootPages = [createDocumentPageWithChildren('root', children)];
const ids = (pages: { page: { id: string } }[] | undefined) =>
(pages ?? []).map(({ page }) => page.id);
const childIds = (from: number, to: number) => children.slice(from, to).map((page) => page.id);
it('renders the first batch of a subtree by default', () => {
const selection = selectPages(
rootPages,
getPDFSearchParams(new URLSearchParams('page=root&only=yes'))
);
expect(selection?.total).toBe(46);
expect(selection?.offset).toBe(0);
expect(ids(selection?.pages)).toEqual(['root', ...childIds(0, 19)]);
expect(selection?.allPages).toHaveLength(46);
});
it('slices the batch from offset to offset + limit', () => {
const selection = selectPages(rootPages, {
page: 'root',
only: true,
limit: 20,
offset: 20,
});
expect(selection?.offset).toBe(20);
expect(ids(selection?.pages)).toEqual(childIds(19, 39));
});
it('returns a shorter last batch', () => {
const selection = selectPages(rootPages, {
page: 'root',
only: true,
limit: 20,
offset: 40,
});
expect(ids(selection?.pages)).toEqual(childIds(39, 45));
});
it('falls back to the last batch when offset is past the end', () => {
const selection = selectPages(rootPages, {
page: 'root',
only: true,
limit: 20,
offset: 100,
});
expect(selection?.offset).toBe(26);
expect(selection?.pages).toHaveLength(20);
});
it('only selects the page itself without only', () => {
const selection = selectPages(rootPages, { page: 'root', limit: 100, offset: 0 });
expect(ids(selection?.pages)).toEqual(['root']);
expect(selection?.total).toBe(1);
});
it('returns null for an unknown page', () => {
expect(selectPages(rootPages, { page: 'missing', limit: 100, offset: 0 })).toBeNull();
});
});
+73 -30
View File
@@ -3,6 +3,7 @@ import { notFound } from 'next/navigation';
import * as React from 'react';
import {
type Revision,
type RevisionPageDocument,
type RevisionPageGroup,
type SiteCustomizationSettings,
@@ -15,8 +16,7 @@ import { ImagesLoadingStatus } from './ImagesLoadingStatus';
import { createPDFLinker, getPagePDFContainerId } from './linker';
import { PageControlButtons } from './PageControlButtons';
import { PDFPrintControls } from './PDFPrintControls';
import { selectPages } from './selectPages';
import { getPDFSearchParams, getPDFURLSearchParams } from './urls';
import { type PDFSearchParams, getPDFSearchParams } from './urls';
import { DocumentView } from '@/components/DocumentView';
import { Trademark } from '@/components/TableOfContents/Trademark';
import type { PolymorphicComponentProp } from '@/components/utils/types';
@@ -27,10 +27,13 @@ import type { GitBookSiteContext, GitBookSpaceContext } from '@/lib/context';
import { getPageDocument } from '@/lib/data';
import { type GitBookLinker, createLinker, linkerWithAbsoluteURLs } from '@/lib/links';
import './pdf.css';
import { resolvePageId } from '@/lib/pages';
import { getLinkerForSiteSpace } from '@/lib/sites';
import { tcls } from '@/lib/tailwind';
import { defaultCustomization } from '@/lib/utils';
const DEFAULT_LIMIT = 100;
/**
* Generate the metadata for the PDF page.
*/
@@ -59,37 +62,13 @@ export async function PDFPage(props: {
const language = await getSpaceLanguage(baseContext);
// Compute the pages to render
const selection = selectPages(baseContext.revision.pages, pdfParams);
if (!selection) {
notFound();
}
const { pages, allPages, offset, total } = selection;
const batchParams = { ...pdfParams, offset };
const { pages, total } = selectPages(baseContext.revision.pages, pdfParams);
const pageIds = pages.map(
({ page }) => [page.id, getPagePDFContainerId(page)] as [string, string]
);
// Build a linker that create anchor links for the pages rendered in the PDF page.
const pageIndexes = new Map(allPages.map(({ page }, index) => [page.id, index]));
const linker = createPDFLinker(baseContext.linker, pages, getPublishedLinker(baseContext), {
getBatchURL: (page) => {
const index = pageIndexes.get(page.id);
if (index === undefined) {
return undefined;
}
// Align on the current batch so these links match the previous/next controls.
const batchOffset = Math.max(
0,
offset + Math.floor((index - offset) / pdfParams.limit) * pdfParams.limit
);
return baseContext.linker.toAbsoluteURL(
baseContext.linker.toPathInSpace(
`~gitbook/pdf?${getPDFURLSearchParams({ ...pdfParams, offset: batchOffset }).toString()}`
)
);
},
});
const linker = createPDFLinker(baseContext.linker, pages, getPublishedLinker(baseContext));
const context: GitBookSpaceContext = {
...baseContext,
@@ -134,7 +113,7 @@ export async function PDFPage(props: {
</div>
<PageControlButtons
params={batchParams}
params={pdfParams}
pageIds={pageIds}
total={total}
trademark={
@@ -147,7 +126,7 @@ export async function PDFPage(props: {
}
/>
{pdfParams.only || offset > 0 ? null : (
{pdfParams.only ? null : (
<PDFSpaceIntro space={context.space} customization={customization} />
)}
{pages.map(({ page }) =>
@@ -294,3 +273,67 @@ function PrintPage(
</div>
);
}
type FlatPageEntry = { page: RevisionPageDocument | RevisionPageGroup; depth: number };
/**
* Compute the ordered flat set of pages to render.
*/
function selectPages(
rootPages: Revision['pages'],
params: PDFSearchParams
): { pages: FlatPageEntry[]; total: number } {
const flattenPage = (
page: RevisionPageDocument | RevisionPageGroup,
depth: number
): FlatPageEntry[] => {
return [
{ page, depth },
...page.pages.flatMap((child) => {
if (child.type !== 'document') {
return [];
}
if (child.hidden) {
return [];
}
return flattenPage(child, depth + 1);
}),
];
};
const limitTo = (entries: FlatPageEntry[]) => {
return {
// Apply a soft-limit, the limit can be controlled by the URL to allow testing
pages: entries.slice(0, params.limit ?? DEFAULT_LIMIT),
total: entries.length,
};
};
if (params.page) {
const found = resolvePageId(rootPages, params.page);
if (!found) {
notFound();
}
if (!params.only) {
return limitTo([{ page: found.page, depth: 0 }]);
}
return limitTo(flattenPage(found.page, 0));
}
const allPages = rootPages.flatMap((page) => {
if (page.type !== 'document' && page.type !== 'group') {
return [];
}
if (page.hidden) {
return [];
}
return flattenPage(page, 0);
});
return limitTo(allPages);
}
@@ -10,6 +10,8 @@ import { Button } from '@/components/primitives';
import { t, tString, useLanguage } from '@/intl/client';
import { tcls } from '@/lib/tailwind';
const limitExtend = 50;
/**
* Dynamic controls to show active page and to let the user select between modes.
*/
@@ -17,7 +19,7 @@ export function PageControlButtons(props: {
params: PDFSearchParams;
/** Array of the [pageId, divId] */
pageIds: [string, string][];
/** Total number of pages targetted by the generation, across all batches */
/** Total number of pages targetted by the generation */
total: number;
/** Trademark to display */
trademark?: React.ReactNode;
@@ -36,10 +38,6 @@ export function PageControlButtons(props: {
const activeIndex = (activeDivId ? divIds.indexOf(activeDivId) : 0) + 1;
const activePageId = pageIds[activeIndex - 1]?.[0];
const batchEnd = params.offset + pageIds.length;
const previousCount = Math.min(params.limit, params.offset);
const nextCount = Math.min(params.limit, total - batchEnd);
return (
<>
<div
@@ -60,8 +58,6 @@ export function PageControlButtons(props: {
...params,
page: activePageId,
only: true,
limit: undefined,
offset: undefined,
}).toString()}`}
variant="secondary"
label={tString(language, 'pdf_mode_only_page')}
@@ -72,8 +68,6 @@ export function PageControlButtons(props: {
...params,
page: undefined,
only: false,
limit: undefined,
offset: undefined,
}).toString()}`}
variant="secondary"
label={tString(language, 'pdf_mode_all')}
@@ -95,7 +89,7 @@ export function PageControlButtons(props: {
'z-50'
)}
>
{previousCount > 0 || nextCount > 0 ? (
{total !== pageIds.length ? (
<div
role="banner"
className={tcls(
@@ -118,32 +112,19 @@ export function PageControlButtons(props: {
className={tcls('size-6', 'mr-3', 'mt-1')}
/>{' '}
<div>
<div>{t(language, 'pdf_limit_reached', total, pageIds.length)}</div>
<div>
{t(language, 'pdf_batch_range', params.offset + 1, batchEnd, total)}
</div>
<div className={tcls('flex', 'flex-row', 'flex-wrap', 'gap-x-3')}>
{previousCount > 0 ? (
<a
href={`?${getPDFURLSearchParams({
...params,
offset: params.offset - previousCount,
}).toString()}`}
className={tcls('underline')}
>
{t(language, 'pdf_batch_previous', previousCount)}
</a>
) : null}
{nextCount > 0 ? (
<a
href={`?${getPDFURLSearchParams({
...params,
offset: batchEnd,
}).toString()}`}
className={tcls('underline')}
>
{t(language, 'pdf_batch_next', nextCount)}
</a>
) : null}
<a
href={`?${getPDFURLSearchParams({
...params,
page: undefined,
only: false,
limit: params.limit + limitExtend,
}).toString()}`}
className={tcls('underline')}
>
{t(language, 'pdf_limit_reached_continue', limitExtend)}
</a>
</div>
</div>
</div>
@@ -165,7 +146,7 @@ export function PageControlButtons(props: {
'border'
)}
>
{t(language, 'pdf_page_of', params.offset + activeIndex, total)}
{t(language, 'pdf_page_of', activeIndex, pageIds.length)}
</div>
</div>
</>
+18 -21
View File
@@ -20,41 +20,38 @@ export function getPagePDFContainerId(
/**
* Create a custom linker for PDF exports.
*
* Pages rendered in the current batch get in-document anchors. Other pages link to the
* published site when possible; pages exported in another batch otherwise link to that batch.
* This linker generates in-document anchor links for pages that are included
* in the current PDF export, using `getPagePDFContainerId` to build the
* target element ID. For pages that are not part of the exported PDF, it
* falls back to URLs pointing to the published site if `publishedLinker` is
* provided, preserving navigability for external content. Otherwise, it uses
* absolute URLs from the base linker.
*
* @param baseLinker - The base GitBook linker used to resolve standard paths and URLs.
* @param pages - The list of pages that are included in the current PDF export.
* @param publishedLinker - Optional linker for the published space for external page links.
* @returns A `GitBookLinker` configured to generate PDF-friendly links.
*/
export function createPDFLinker(
baseLinker: GitBookLinker,
pages: { page: Revision['pages'][number] }[],
publishedLinker?: GitBookLinker,
options: {
/** URL of the export batch rendering a page, for pages outside the current batch. */
getBatchURL?: (page: RevisionPageDocument | RevisionPageGroup) => string | undefined;
} = {}
publishedLinker?: GitBookLinker
): GitBookLinker {
const pageIds = new Set(pages.map((p) => p.page.id));
return {
...baseLinker,
toPathForPage(input) {
if (pageIds.has(input.page.id)) {
if (pages.some((p) => p.page.id === input.page.id)) {
return `#${getPagePDFContainerId(input.page, input.anchor)}`;
}
// A published page outlives the export URL, so prefer it for documents.
if (input.page.type !== RevisionPageType.Group && publishedLinker) {
return publishedLinker.toPathForPage(input);
}
const batchURL = options.getBatchURL?.(input.page);
if (batchURL) {
return `${batchURL}#${getPagePDFContainerId(input.page, input.anchor)}`;
}
if (input.page.type === RevisionPageType.Group) {
return '#';
}
// For pages that are not embedded in this PDF export, keep links on the published site.
if (publishedLinker) {
return publishedLinker.toPathForPage(input);
}
return baseLinker.toAbsoluteURL(baseLinker.toPathForPage(input));
},
};
@@ -1,92 +0,0 @@
import type { Revision, RevisionPageDocument, RevisionPageGroup } from '@gitbook/api';
import type { PDFSearchParams } from './urls';
import { resolvePageId } from '@/lib/pages';
export type FlatPageEntry = { page: RevisionPageDocument | RevisionPageGroup; depth: number };
export interface PDFPageSelection {
/** Pages rendered in the current batch */
pages: FlatPageEntry[];
/** Every page targeted by the export, across all batches */
allPages: FlatPageEntry[];
/** Index in `allPages` of the first page of the batch */
offset: number;
/** Total number of pages targeted by the export */
total: number;
}
/**
* Compute the ordered flat set of pages targeted by the export, and the batch to render.
* Returns `null` if the requested page doesn't exist.
*/
export function selectPages(
rootPages: Revision['pages'],
params: Pick<PDFSearchParams, 'page' | 'only' | 'limit' | 'offset'>
): PDFPageSelection | null {
const allPages = selectAllPages(rootPages, params);
if (!allPages) {
return null;
}
const total = allPages.length;
// Fall back to the last batch rather than rendering an empty one.
const offset = params.offset < total ? params.offset : Math.max(0, total - params.limit);
return {
pages: allPages.slice(offset, offset + params.limit),
allPages,
offset,
total,
};
}
function selectAllPages(
rootPages: Revision['pages'],
params: Pick<PDFSearchParams, 'page' | 'only'>
): FlatPageEntry[] | null {
if (params.page) {
const found = resolvePageId(rootPages, params.page);
if (!found) {
return null;
}
if (!params.only) {
return [{ page: found.page, depth: 0 }];
}
return flattenPage(found.page, 0);
}
return rootPages.flatMap((page) => {
if (page.type !== 'document' && page.type !== 'group') {
return [];
}
if (page.hidden) {
return [];
}
return flattenPage(page, 0);
});
}
function flattenPage(
page: RevisionPageDocument | RevisionPageGroup,
depth: number
): FlatPageEntry[] {
return [
{ page, depth },
...page.pages.flatMap((child) => {
if (child.type !== 'document') {
return [];
}
if (child.hidden) {
return [];
}
return flattenPage(child, depth + 1);
}),
];
}
+12 -56
View File
@@ -1,61 +1,33 @@
/** Default number of pages rendered per request when exporting the whole space. */
export const PDF_DEFAULT_LIMIT = 100;
/**
* Default number of pages rendered per request when exporting a page and its subtree.
* Subtrees are often OpenAPI references, which are much heavier to render than prose
* and get the request killed for CPU/memory at higher limits.
*/
export const PDF_SUBTREE_DEFAULT_LIMIT = 20;
const DEFAULT_LIMIT = 100;
export interface PDFSearchParams {
/** Page to export. If none is passed, all pages are exported. */
page?: string;
/** If true, the `page` is exported with its descendants */
/** If true, only the `page` is exported, and not its descendant */
only?: boolean;
/** Maximum number of pages to render in this batch */
/** Limit the number of pages */
limit: number;
/** Index of the first page to render in this batch */
offset: number;
/** URL to redirect back to */
back?: string;
}
/**
* Params accepted when building a PDF export URL. `limit` and `offset` fall back to the defaults.
*/
export type PDFURLParams = Omit<PDFSearchParams, 'limit' | 'offset'> & {
limit?: number;
offset?: number;
};
/**
* Default batch size for a given PDF export.
*/
export function getDefaultPDFLimit(params: Pick<PDFSearchParams, 'page' | 'only'>): number {
return params.page && params.only ? PDF_SUBTREE_DEFAULT_LIMIT : PDF_DEFAULT_LIMIT;
}
/**
* Get the PDF export params from the URL serch params.
*/
export function getPDFSearchParams(searchParams: URLSearchParams): PDFSearchParams {
const page = searchParams.has('page') ? (searchParams.get('page') ?? '') : undefined;
const only = searchParams.has('only') ? true : undefined;
const params: PDFSearchParams = {
limit:
parseInteger(searchParams.get('limit'), { min: 1 }) ??
getDefaultPDFLimit({ page, only }),
offset: parseInteger(searchParams.get('offset'), { min: 0 }) ?? 0,
limit: DEFAULT_LIMIT,
};
if (page !== undefined) {
params.page = page;
if (searchParams.has('page')) {
params.page = searchParams.get('page') ?? '';
}
if (only) {
if (searchParams.has('only')) {
params.only = true;
}
if (searchParams.has('limit')) {
params.limit = Number(searchParams.get('limit'));
}
if (searchParams.has('back')) {
params.back = searchParams.get('back') ?? '';
}
@@ -67,7 +39,7 @@ export function getPDFSearchParams(searchParams: URLSearchParams): PDFSearchPara
* Get the URL search params to use for a PDF export.
*/
export function getPDFURLSearchParams(
params: PDFURLParams,
params: PDFSearchParams,
searchParams = new URLSearchParams({})
): URLSearchParams {
if (params?.page) {
@@ -81,16 +53,9 @@ export function getPDFURLSearchParams(
searchParams.delete('only');
}
// Persist limit, offset and back
// Persist limit and back
if (params?.limit) {
searchParams.set('limit', String(params.limit));
} else {
searchParams.delete('limit');
}
if (params?.offset) {
searchParams.set('offset', String(params.offset));
} else {
searchParams.delete('offset');
}
if (params?.back) {
searchParams.set('back', String(params.back));
@@ -98,12 +63,3 @@ export function getPDFURLSearchParams(
return searchParams;
}
function parseInteger(value: string | null, options: { min: number }): number | undefined {
if (value === null || value.trim() === '') {
return undefined;
}
const parsed = Number(value);
return Number.isInteger(parsed) && parsed >= options.min ? parsed : undefined;
}
@@ -67,7 +67,7 @@ export function ActionOpenAssistant(props: {
href: page.href,
});
}
assistant.open();
assistant.open(undefined, 'page');
}}
/>
);
@@ -1,4 +1,8 @@
import type { JSONDocument, RevisionPageDocument, SiteInsightsDisplayContext } from '@gitbook/api';
import {
type JSONDocument,
type RevisionPageDocument,
SiteInsightsDisplayContext,
} from '@gitbook/api';
import { DocumentView, DocumentViewSkeleton } from '../DocumentView';
import { CurrentPageProvider } from '../hooks/useCurrentPage';
@@ -127,6 +131,7 @@ export async function PageBody(props: {
ancestors={ancestors}
withRSSFeed={contentHasUpdates}
hasAPIBlocks={hasAPIBlocks}
asEmbeddable={insightsDisplayContext === SiteInsightsDisplayContext.Embed}
/>
{document && !isNodeEmpty(document) ? (
<OptionalSuspense
@@ -19,14 +19,17 @@ import {
import { PageAsideToggleButton } from '../PageAside/PageAsideButton';
import { PageIcon } from '../PageIcon';
import { getPDFURLSearchParams } from '../PDF';
import { findBestTargetURL } from '../SiteSections/encodeClientSiteSections';
import {
findBestTargetURL,
getTargetURLForSiteSpace,
} from '../SiteSections/encodeClientSiteSections';
import { categorizeVariants } from '../SpaceLayout/categorizeVariants';
import { BreadcrumbItemDropdown, type BreadcrumbSibling } from './BreadcrumbItemDropdown';
import { PageTags } from './PageTags';
import type { GitBookSiteContext, SiteStructureNode } from '@/lib/context';
import { hasAdaptiveMcpEndpoint } from '@/lib/mcp/endpoints';
import { type AncestorRevisionPage, resolveFirstDocument } from '@/lib/pages';
import { getLocalizedTitle, getSiteSpaceURL } from '@/lib/sites';
import { getLocalizedTitle } from '@/lib/sites';
import { tcls } from '@/lib/tailwind';
import { getPageRSSURL } from '@/routes/rss';
@@ -41,8 +44,10 @@ export async function PageHeader(props: {
* exactly as-is.
*/
hasAPIBlocks: boolean;
/** Keep the context crumbs' links inside the embed rather than sending readers to the full site. */
asEmbeddable: boolean;
}) {
const { context, page, ancestors, withRSSFeed, hasAPIBlocks } = props;
const { context, page, ancestors, withRSSFeed, hasAPIBlocks, asEmbeddable } = props;
const { revision, linker } = context;
const hasAncestors = ancestors.length > 0;
@@ -82,7 +87,10 @@ export async function PageHeader(props: {
// Section groups have no URL of their own; only sections are navigable. Resolve the
// section to the site space matching the current variant so switching sections keeps
// the reader on their current variant (same logic as the section tabs).
href: node.object === 'site-section' ? findBestTargetURL(context, node) : undefined,
href:
node.object === 'site-section'
? findBestTargetURL(context, node, asEmbeddable)
: undefined,
label: getLocalizedTitle(node, context.locale),
icon: node.icon,
siblings: siblings
@@ -92,7 +100,7 @@ export async function PageHeader(props: {
// Don't offer hidden sections/groups as switch targets.
.filter((sibling) => !visibleSectionIds || visibleSectionIds.has(sibling.id))
.map((sibling) => {
const href = getSectionNodeURL(context, sibling);
const href = getSectionNodeURL(context, sibling, asEmbeddable);
// Keep siblings whose URL is "" (the site's first page); only drop the ones
// with no resolvable URL at all.
return href !== undefined
@@ -112,7 +120,7 @@ export async function PageHeader(props: {
if (currentSiteSpace) {
contextCrumbs.push({
key: `variant-${currentSiteSpace.id}`,
href: getSiteSpaceURL(context, currentSiteSpace),
href: getTargetURLForSiteSpace(context, currentSiteSpace, asEmbeddable),
label: getLocalizedTitle(currentSiteSpace, context.locale),
siblings: [],
// Reuse the header's variant switcher rather than plain per-variant links, so each entry
@@ -122,7 +130,7 @@ export async function PageHeader(props: {
slimSpaces: variantSpaces.map((siteSpace) => ({
id: siteSpace.id,
title: getLocalizedTitle(siteSpace, context.locale),
url: getSiteSpaceURL(context, siteSpace),
url: getTargetURLForSiteSpace(context, siteSpace, asEmbeddable),
isActive: siteSpace.id === currentSiteSpace.id,
spaceId: siteSpace.space.id,
})),
@@ -448,9 +456,13 @@ function collectSectionNodeIds(list: SiteStructureNode[]): Set<string> {
* The URL resolves to the site space matching the current variant (same logic as the section tabs),
* so switching sections keeps the reader on their current variant.
*/
function getSectionNodeURL(context: GitBookSiteContext, node: SectionNode): string | undefined {
function getSectionNodeURL(
context: GitBookSiteContext,
node: SectionNode,
asEmbeddable: boolean
): string | undefined {
const section = findFirstSection(node);
return section ? findBestTargetURL(context, section) : undefined;
return section ? findBestTargetURL(context, section, asEmbeddable) : undefined;
}
/**
@@ -533,6 +545,7 @@ function getPageActionsURLs({
`~gitbook/pdf?${getPDFURLSearchParams({
page: page.id,
only: true,
limit: 100,
}).toString()}`
)
: undefined,
@@ -284,11 +284,11 @@ export async function getSitePageData(props: SitePageProps) {
if (pathname !== null) {
// If the pathname was not normalized, redirect to the normalized version
// before trying to resolve the page again
redirect(context.linker.toPathInSpace(pathname));
redirect(context.linker.toPathForPagePath({ path: pathname }));
} else {
// If the page is not found and we are in fallback mode, return a redirect to the basepath
if (context.isFallback) {
redirect(context.linker.toPathInSpace('/'));
redirect(context.linker.toPathForPagePath({ path: '/' }));
}
notFound();
}
@@ -16,6 +16,7 @@ import { useSetSearchState } from '../Search';
import { fetchSiteIndex } from '../Search/site-index';
import { SiteAuthLoginButton } from '../SiteAuth/SiteAuthLoginLink';
import {
useIsLoggedInVisitor,
useSiteAdaptiveAuthLoginHref,
useSiteIndexURL,
useSpaceBasePath,
@@ -44,6 +45,9 @@ export function SitePageNotFound() {
const setSearchState = useSetSearchState();
const { assistants } = useAI();
const isAuthenticated = useIsLoggedInVisitor();
const copy = getNotFoundCopy({ hasAdaptiveLogin: !!adaptiveAuthLoginHref, isAuthenticated });
// Show the assistant input when a non-search assistant is available (i.e. not just ask-AI).
const assistant = assistants.find((candidate) => candidate.mode !== 'search') ?? null;
const inputLabel = tString(language, assistant ? 'search_or_ask' : 'search');
@@ -124,21 +128,20 @@ export function SitePageNotFound() {
'text-tint-strong'
)}
>
{t(
language,
adaptiveAuthLoginHref
? 'notfound_adaptive_title'
: 'notfound_title'
)}
{t(language, copy.title)}
</h1>
<p className={tcls('text-base', 'text-tint')}>
{t(
language,
adaptiveAuthLoginHref ? 'notfound_adaptive' : 'notfound'
)}
<p className={tcls('text-base', 'text-tint', 'text-center')}>
{t(language, copy.message)}
</p>
</div>
{adaptiveAuthLoginHref ? (
{adaptiveAuthLoginHref && isAuthenticated ? (
// Re-running login refreshes the visitor's claims, e.g. after a role change.
<SiteAuthLoginButton
href={adaptiveAuthLoginHref}
variant="secondary"
label={t(language, 'notfound_adaptive_login_again')}
/>
) : adaptiveAuthLoginHref ? (
<div className="flex flex-col items-center gap-4">
<SiteAuthLoginButton
href={adaptiveAuthLoginHref}
@@ -190,6 +193,19 @@ export function SitePageNotFound() {
);
}
function getNotFoundCopy(args: { hasAdaptiveLogin: boolean; isAuthenticated: boolean }) {
if (!args.hasAdaptiveLogin) {
return { title: 'notfound_title', message: 'notfound' } as const;
}
if (args.isAuthenticated) {
return {
title: 'notfound_adaptive_no_access_title',
message: 'notfound_adaptive_no_access',
} as const;
}
return { title: 'notfound_adaptive_title', message: 'notfound_adaptive' } as const;
}
/**
* List of related pages, with skeleton rows while they load. Renders nothing once we know
* there are no suggestions.
@@ -201,7 +201,7 @@ function getTargetURLForSection(
return getSectionURL(context, section);
}
function getTargetURLForSiteSpace(
export function getTargetURLForSiteSpace(
context: GitBookSiteContext,
siteSpace: SiteSpace,
asEmbeddable: boolean
@@ -72,6 +72,7 @@ export function SpaceLayoutServerContext(props: SpaceLayoutProps) {
<SpaceLayoutContextProvider
basePath={context.linker.toPathInSpace('')}
siteAdaptiveAuthLoginHref={siteAdaptiveAuthLoginHref}
isLoggedInVisitor={context.isLoggedInVisitor}
siteIndexURL={context.linker.toPathInSite('~gitbook/site-index')}
>
<AdaptiveVisitorContextProvider
@@ -5,6 +5,7 @@ import React from 'react';
const SpaceLayoutContext = React.createContext({
basePath: '',
siteAdaptiveAuthLoginHref: null as string | null,
isLoggedInVisitor: false,
siteIndexURL: '',
});
@@ -15,14 +16,21 @@ export function SpaceLayoutContextProvider(
props: React.PropsWithChildren<{
basePath: string;
siteAdaptiveAuthLoginHref?: string | null;
isLoggedInVisitor?: boolean;
siteIndexURL: string;
}>
) {
const { basePath, siteAdaptiveAuthLoginHref = null, siteIndexURL, children } = props;
const {
basePath,
siteAdaptiveAuthLoginHref = null,
isLoggedInVisitor = false,
siteIndexURL,
children,
} = props;
const value = React.useMemo(
() => ({ basePath, siteAdaptiveAuthLoginHref, siteIndexURL }),
[basePath, siteAdaptiveAuthLoginHref, siteIndexURL]
() => ({ basePath, siteAdaptiveAuthLoginHref, isLoggedInVisitor, siteIndexURL }),
[basePath, siteAdaptiveAuthLoginHref, isLoggedInVisitor, siteIndexURL]
);
return <SpaceLayoutContext.Provider value={value}>{children}</SpaceLayoutContext.Provider>;
@@ -50,6 +58,17 @@ export function useSiteAdaptiveAuthLoginHref() {
return context.siteAdaptiveAuthLoginHref;
}
/**
* Return whether the visitor has a visitor auth token, with or without claims.
*/
export function useIsLoggedInVisitor() {
const context = React.useContext(SpaceLayoutContext);
if (!context) {
throw new Error('SpaceLayoutContext not found');
}
return context.isLoggedInVisitor;
}
/**
* Return the URL of the site search index (`~gitbook/site-index`).
*/
+8 -5
View File
@@ -77,10 +77,14 @@ export const ar: TranslationLanguage = {
notfound_title: 'الصفحة غير موجودة',
notfound_link: 'يشير هذا الرابط إلى صفحة تمت إزالتها أو لم تعد موجودة.',
notfound: 'الصفحة التي تبحث عنها غير موجودة.',
notfound_adaptive_title: 'الصفحة غير متاحة',
notfound_adaptive: 'قد تكون هذه الصفحة موجودة، لكن قد تحتاج إلى تسجيل الدخول للوصول إليها.',
notfound_adaptive_title: 'سجّل الدخول لعرض هذه الصفحة',
notfound_adaptive: 'قد تتطلب هذه الصفحة تسجيل الدخول. إذا اتبعت رابطًا، فتحقق من صحته.',
notfound_adaptive_login: 'تسجيل الدخول',
notfound_adaptive_registration_hint: 'قد يكون التسجيل متاحًا حسب المؤسسة.',
notfound_adaptive_no_access_title: 'قد لا تملك صلاحية الوصول إلى هذه الصفحة',
notfound_adaptive_no_access:
'قد لا تكون هذه الصفحة موجودة، أو قد لا يملك حسابك صلاحية الوصول إليها. إذا اتبعت رابطًا، فتحقق من صحته.',
notfound_adaptive_login_again: 'تسجيل الدخول مجددًا',
notfound_goto_home: 'الانتقال إلى الصفحة الرئيسية',
notfound_suggestions_title: 'ربما تبحث عن',
unexpected_error_title: 'حدث خطأ',
@@ -96,9 +100,8 @@ export const ar: TranslationLanguage = {
pdf_page_of: '${1} من ${2}',
pdf_mode_only_page: 'هذه الصفحة فقط',
pdf_mode_all: 'كل الصفحات',
pdf_batch_range: 'عرض الصفحات ${1}–${2} من ${3}.',
pdf_batch_previous: 'الصفحات الـ ${1} السابقة',
pdf_batch_next: 'الصفحات الـ ${1} التالية',
pdf_limit_reached: 'تعذر إنشاء ملف PDF لـ ${1} صفحات، وتوقف الإنشاء عند ${2}.',
pdf_limit_reached_continue: 'التوسيع بإضافة ${1} صفحات أخرى.',
more: 'المزيد',
link_tooltip_external_link: 'رابط خارجي إلى',
link_tooltip_email: 'إرسال بريد إلكتروني إلى',
+9 -5
View File
@@ -78,12 +78,16 @@ export const bg: TranslationLanguage = {
notfound_title: 'Страницата не е намерена',
notfound_link: 'Тази връзка сочи към страница, която е премахната или вече не съществува.',
notfound: 'Страницата, която търсите, не съществува.',
notfound_adaptive_title: 'Страницата не е налична',
notfound_adaptive_title: 'Влезте, за да видите тази страница',
notfound_adaptive:
'Тази страница може да съществува, но може да трябва да влезете, за да я достъпите.',
'Тази страница може да изисква вход. Ако сте последвали връзка, проверете дали е правилна.',
notfound_adaptive_login: 'Вход',
notfound_adaptive_registration_hint:
'Регистрацията може да е възможна в зависимост от организацията.',
notfound_adaptive_no_access_title: 'Възможно е да нямате достъп до тази страница',
notfound_adaptive_no_access:
'Тази страница може да не съществува или профилът ви може да няма достъп до нея. Ако сте последвали връзка, проверете дали е правилна.',
notfound_adaptive_login_again: 'Повторен вход',
notfound_goto_home: 'Към началната страница',
notfound_suggestions_title: 'Може би търсите',
unexpected_error_title: 'Възникна грешка',
@@ -99,9 +103,9 @@ export const bg: TranslationLanguage = {
pdf_page_of: '${1} от ${2}',
pdf_mode_only_page: 'Само тази страница',
pdf_mode_all: 'Всички страници',
pdf_batch_range: 'Показани са страници ${1}–${2} от ${3}.',
pdf_batch_previous: 'Предишни ${1} страници',
pdf_batch_next: 'Следващи ${1} страници',
pdf_limit_reached:
'PDF файлът за ${1} страници не можа да бъде генериран, генерирането спря на ${2}.',
pdf_limit_reached_continue: 'Разширяване с още ${1} страници.',
more: 'Още',
link_tooltip_external_link: 'Външна връзка към',
link_tooltip_email: 'Изпращане на имейл до',
+9 -5
View File
@@ -77,11 +77,15 @@ export const cs: TranslationLanguage = {
notfound_title: 'Stránka nenalezena',
notfound_link: 'Tento odkaz vede na stránku, která byla odstraněna nebo již neexistuje.',
notfound: 'Stránka, kterou hledáte, neexistuje.',
notfound_adaptive_title: 'Stránka není dostupná',
notfound_adaptive_title: 'Pro zobrazení této stránky se přihlaste',
notfound_adaptive:
'Tato stránka může existovat, ale pro přístup se možná budete muset přihlásit.',
'Tato stránka může vyžadovat přihlášení. Pokud jste přešli z odkazu, zkontrolujte, zda je správný.',
notfound_adaptive_login: 'Přihlásit se',
notfound_adaptive_registration_hint: 'Registrace může být dostupná v závislosti na organizaci.',
notfound_adaptive_no_access_title: 'K této stránce možná nemáte přístup',
notfound_adaptive_no_access:
'Tato stránka možná neexistuje nebo k ní váš účet nemá přístup. Pokud jste přešli z odkazu, zkontrolujte, zda je správný.',
notfound_adaptive_login_again: 'Přihlásit se znovu',
notfound_goto_home: 'Přejít na domovskou stránku',
notfound_suggestions_title: 'Možná hledáte',
unexpected_error_title: 'Došlo k chybě',
@@ -97,9 +101,9 @@ export const cs: TranslationLanguage = {
pdf_page_of: '${1} z ${2}',
pdf_mode_only_page: 'Pouze tato stránka',
pdf_mode_all: 'Všechny stránky',
pdf_batch_range: 'Zobrazeny stránky ${1}–${2} z ${3}.',
pdf_batch_previous: 'Předchozích ${1} stránek',
pdf_batch_next: 'Dalších ${1} stránek',
pdf_limit_reached:
'Nepodařilo se vygenerovat PDF pro ${1} stránek, generování se zastavilo na ${2}.',
pdf_limit_reached_continue: 'Rozšířit o dalších ${1} stránek.',
more: 'Více',
link_tooltip_external_link: 'Externí odkaz na',
link_tooltip_email: 'Odeslat e-mail na',
+8 -5
View File
@@ -77,11 +77,15 @@ export const da: TranslationLanguage = {
notfound_title: 'Siden blev ikke fundet',
notfound_link: 'Dette link peger på en side, der er blevet fjernet eller ikke længere findes.',
notfound: 'Siden, du leder efter, findes ikke.',
notfound_adaptive_title: 'Siden er ikke tilgængelig',
notfound_adaptive_title: 'Log ind for at se denne side',
notfound_adaptive:
'Denne side findes muligvis, men du skal muligvis logge ind for at få adgang.',
'Denne side kræver muligvis, at du logger ind. Hvis du har fulgt et link, så tjek, at det er korrekt.',
notfound_adaptive_login: 'Log ind',
notfound_adaptive_registration_hint: 'Registrering kan være mulig afhængigt af organisationen.',
notfound_adaptive_no_access_title: 'Du har muligvis ikke adgang til denne side',
notfound_adaptive_no_access:
'Denne side findes muligvis ikke, eller din konto har muligvis ikke adgang til den. Hvis du har fulgt et link, så tjek, at det er korrekt.',
notfound_adaptive_login_again: 'Log ind igen',
notfound_goto_home: 'Gå til forsiden',
notfound_suggestions_title: 'Du leder måske efter',
unexpected_error_title: 'Der opstod en fejl',
@@ -97,9 +101,8 @@ export const da: TranslationLanguage = {
pdf_page_of: '${1} af ${2}',
pdf_mode_only_page: 'Kun denne side',
pdf_mode_all: 'Alle sider',
pdf_batch_range: 'Viser sider ${1}–${2} af ${3}.',
pdf_batch_previous: 'Forrige ${1} sider',
pdf_batch_next: 'Næste ${1} sider',
pdf_limit_reached: 'Kunne ikke generere PDF for ${1} sider, genereringen stoppede ved ${2}.',
pdf_limit_reached_continue: 'Udvid med ${1} flere sider.',
more: 'Mere',
link_tooltip_external_link: 'Eksternt link til',
link_tooltip_email: 'Send e-mail til',
+9 -5
View File
@@ -80,12 +80,16 @@ export const de: TranslationLanguage = {
notfound_link:
'Dieser Link verweist auf eine Seite, die entfernt wurde oder nicht mehr existiert.',
notfound: 'Die gesuchte Seite existiert nicht.',
notfound_adaptive_title: 'Seite nicht verfügbar',
notfound_adaptive_title: 'Melden Sie sich an, um diese Seite anzuzeigen',
notfound_adaptive:
'Diese Seite existiert möglicherweise, aber Sie müssen sich eventuell anmelden, um darauf zuzugreifen.',
'Für diese Seite ist möglicherweise eine Anmeldung erforderlich. Wenn Sie einem Link gefolgt sind, prüfen Sie, ob er korrekt ist.',
notfound_adaptive_login: 'Anmelden',
notfound_adaptive_registration_hint:
'Die Registrierung ist je nach Organisation möglicherweise verfügbar.',
notfound_adaptive_no_access_title: 'Sie haben möglicherweise keinen Zugriff auf diese Seite',
notfound_adaptive_no_access:
'Diese Seite existiert möglicherweise nicht, oder Ihr Konto hat keinen Zugriff darauf. Wenn Sie einem Link gefolgt sind, prüfen Sie, ob er korrekt ist.',
notfound_adaptive_login_again: 'Erneut anmelden',
notfound_goto_home: 'Zur Startseite',
notfound_suggestions_title: 'Vielleicht suchen Sie nach',
unexpected_error_title: 'Ein Fehler ist aufgetreten',
@@ -102,9 +106,9 @@ export const de: TranslationLanguage = {
pdf_page_of: '${1} von ${2}',
pdf_mode_only_page: 'Nur diese Seite',
pdf_mode_all: 'Alle Seiten',
pdf_batch_range: 'Seiten ${1}–${2} von ${3}.',
pdf_batch_previous: 'Vorherige ${1} Seiten',
pdf_batch_next: 'Nächste ${1} Seiten',
pdf_limit_reached:
'Das PDF konnte für ${1} Seiten nicht generiert werden, Generierung wurde bei ${2} gestoppt.',
pdf_limit_reached_continue: 'Mit ${1} weiteren Seiten erweitern.',
more: 'Mehr',
link_tooltip_external_link: 'Externer Link zu',
link_tooltip_email: 'E-Mail senden an',
+9 -5
View File
@@ -78,12 +78,16 @@ export const el: TranslationLanguage = {
notfound_title: 'Η σελίδα δεν βρέθηκε',
notfound_link: 'Αυτός ο σύνδεσμος οδηγεί σε μια σελίδα που έχει αφαιρεθεί ή δεν υπάρχει πλέον.',
notfound: 'Η σελίδα που αναζητάτε δεν υπάρχει.',
notfound_adaptive_title: 'Η σελίδα δεν είναι διαθέσιμη',
notfound_adaptive_title: 'Συνδεθείτε για να δείτε αυτή τη σελίδα',
notfound_adaptive:
'Αυτή η σελίδα μπορεί να υπάρχει, αλλά ίσως χρειαστεί να συνδεθείτε για πρόσβαση.',
'Αυτή η σελίδα ενδέχεται να απαιτεί σύνδεση. Αν ακολουθήσατε έναν σύνδεσμο, ελέγξτε ότι είναι σωστός.',
notfound_adaptive_login: 'Σύνδεση',
notfound_adaptive_registration_hint:
'Η εγγραφή ενδέχεται να είναι διαθέσιμη ανάλογα με τον οργανισμό.',
notfound_adaptive_no_access_title: 'Ίσως δεν έχετε πρόσβαση σε αυτή τη σελίδα',
notfound_adaptive_no_access:
'Αυτή η σελίδα ενδέχεται να μην υπάρχει ή ο λογαριασμός σας ενδέχεται να μην έχει πρόσβαση σε αυτήν. Αν ακολουθήσατε έναν σύνδεσμο, ελέγξτε ότι είναι σωστός.',
notfound_adaptive_login_again: 'Επανασύνδεση',
notfound_goto_home: 'Μετάβαση στην αρχική σελίδα',
notfound_suggestions_title: 'Ίσως αναζητάτε',
unexpected_error_title: 'Παρουσιάστηκε σφάλμα',
@@ -100,9 +104,9 @@ export const el: TranslationLanguage = {
pdf_page_of: '${1} από ${2}',
pdf_mode_only_page: 'Μόνο αυτή η σελίδα',
pdf_mode_all: 'Όλες οι σελίδες',
pdf_batch_range: 'Εμφάνιση σελίδων ${1}–${2} από ${3}.',
pdf_batch_previous: 'Προηγούμενες ${1} σελίδες',
pdf_batch_next: 'Επόμενες ${1} σελίδες',
pdf_limit_reached:
'Δεν ήταν δυνατή η δημιουργία PDF για ${1} σελίδες, η δημιουργία σταμάτησε στο ${2}.',
pdf_limit_reached_continue: 'Επέκταση με ${1} ακόμη σελίδες.',
more: 'Περισσότερα',
link_tooltip_external_link: 'Εξωτερικός σύνδεσμος προς',
link_tooltip_email: 'Αποστολή email σε',
+9 -5
View File
@@ -75,11 +75,16 @@ export const en = {
notfound_title: 'Page not found',
notfound_link: 'This link points to a page that has been removed or no longer exists.',
notfound: "The page you're looking for doesn't exist.",
notfound_adaptive_title: 'Page unavailable',
notfound_adaptive: 'This page may exist, but you may need to log in to access it.',
notfound_adaptive_title: 'Log in to view this page',
notfound_adaptive:
"This page may require you to log in. If you followed a link, check that it's correct.",
notfound_adaptive_login: 'Log in',
notfound_adaptive_registration_hint:
'Registration may be available depending on the organization.',
notfound_adaptive_no_access_title: 'You may not have access to this page',
notfound_adaptive_no_access:
"This page may not exist, or your account may not have access to it. If you followed a link, check that it's correct.",
notfound_adaptive_login_again: 'Log in again',
notfound_goto_home: 'Go to homepage',
notfound_suggestions_title: 'You might be looking for',
unexpected_error_title: 'An error occurred',
@@ -95,9 +100,8 @@ export const en = {
pdf_page_of: '${1} of ${2}',
pdf_mode_only_page: 'Only this page',
pdf_mode_all: 'All pages',
pdf_batch_range: 'Showing pages ${1}–${2} of ${3}.',
pdf_batch_previous: 'Previous ${1} pages',
pdf_batch_next: 'Next ${1} pages',
pdf_limit_reached: "Couldn't generate the PDF for ${1} pages, generation stopped at ${2}.",
pdf_limit_reached_continue: 'Extend with ${1} more pages.',
more: 'More',
link_tooltip_external_link: 'External link to',
link_tooltip_email: 'Send an email to',
+9 -5
View File
@@ -79,12 +79,16 @@ export const es: TranslationLanguage = {
notfound_title: 'Página no encontrada',
notfound_link: 'Este enlace apunta a una página que ha sido eliminada o ya no existe.',
notfound: 'La página que buscas no existe.',
notfound_adaptive_title: 'Página no disponible',
notfound_adaptive_title: 'Inicia sesión para ver esta página',
notfound_adaptive:
'Esta página puede existir, pero es posible que debas iniciar sesión para acceder.',
'Es posible que esta página requiera iniciar sesión. Si has seguido un enlace, comprueba que sea correcto.',
notfound_adaptive_login: 'Iniciar sesión',
notfound_adaptive_registration_hint:
'El registro puede estar disponible según la organización.',
notfound_adaptive_no_access_title: 'Es posible que no tengas acceso a esta página',
notfound_adaptive_no_access:
'Es posible que esta página no exista o que tu cuenta no tenga acceso a ella. Si has seguido un enlace, comprueba que sea correcto.',
notfound_adaptive_login_again: 'Volver a iniciar sesión',
notfound_goto_home: 'Ir al inicio',
notfound_suggestions_title: 'Quizás estés buscando',
unexpected_error_title: 'Ocurrió un error',
@@ -101,9 +105,9 @@ export const es: TranslationLanguage = {
pdf_page_of: '${1} de ${2}',
pdf_mode_only_page: 'Solo esta página',
pdf_mode_all: 'Todas las páginas',
pdf_batch_range: 'Mostrando las páginas ${1}–${2} de ${3}.',
pdf_batch_previous: '${1} páginas anteriores',
pdf_batch_next: '${1} páginas siguientes',
pdf_limit_reached:
'No se pudo generar el PDF para ${1} páginas, la generación se detuvo en ${2}.',
pdf_limit_reached_continue: 'Extender con ${1} páginas más.',
more: 'Más',
link_tooltip_external_link: 'Enlace externo a',
link_tooltip_email: 'Enviar un correo electrónico a',
+9 -5
View File
@@ -77,11 +77,16 @@ export const et: TranslationLanguage = {
notfound_title: 'Lehte ei leitud',
notfound_link: 'See link viitab lehele, mis on eemaldatud või mida enam ei eksisteeri.',
notfound: 'Lehte, mida otsite, ei eksisteeri.',
notfound_adaptive_title: 'Leht pole saadaval',
notfound_adaptive: 'See leht võib olemas olla, kuid juurdepääsuks võib olla vaja sisse logida.',
notfound_adaptive_title: 'Selle lehe vaatamiseks logi sisse',
notfound_adaptive:
'See leht võib nõuda sisselogimist. Kui järgisid linki, kontrolli, et see oleks õige.',
notfound_adaptive_login: 'Logi sisse',
notfound_adaptive_registration_hint:
'Registreerimine võib olla saadaval olenevalt organisatsioonist.',
notfound_adaptive_no_access_title: 'Sul ei pruugi olla sellele lehele juurdepääsu',
notfound_adaptive_no_access:
'Seda lehte ei pruugi olla olemas või sinu kontol ei pruugi olla sellele juurdepääsu. Kui järgisid linki, kontrolli, et see oleks õige.',
notfound_adaptive_login_again: 'Logi uuesti sisse',
notfound_goto_home: 'Mine avalehele',
notfound_suggestions_title: 'Võib-olla otsite',
unexpected_error_title: 'Ilmnes tõrge',
@@ -97,9 +102,8 @@ export const et: TranslationLanguage = {
pdf_page_of: '${1}/${2}',
pdf_mode_only_page: 'Ainult see leht',
pdf_mode_all: 'Kõik lehed',
pdf_batch_range: 'Kuvatakse lehti ${1}–${2}/${3}.',
pdf_batch_previous: 'Eelmised ${1} lehte',
pdf_batch_next: 'Järgmised ${1} lehte',
pdf_limit_reached: 'PDF-i ei saanud luua ${1} lehe jaoks, loomine peatus kohas ${2}.',
pdf_limit_reached_continue: 'Laienda veel ${1} lehe võrra.',
more: 'Rohkem',
link_tooltip_external_link: 'Väline link aadressile',
link_tooltip_email: 'Saada e-kiri aadressile',
+8 -5
View File
@@ -78,12 +78,16 @@ export const fi: TranslationLanguage = {
notfound_title: 'Sivua ei löytynyt',
notfound_link: 'Tämä linkki osoittaa sivulle, joka on poistettu tai jota ei enää ole.',
notfound: 'Etsimääsi sivua ei ole olemassa.',
notfound_adaptive_title: 'Sivu ei ole saatavilla',
notfound_adaptive_title: 'Kirjaudu sisään nähdäksesi tämän sivun',
notfound_adaptive:
'Tämä sivu voi olla olemassa, mutta sen käyttö voi edellyttää kirjautumista.',
'Tämä sivu saattaa vaatia kirjautumisen. Jos seurasit linkkiä, tarkista, että se on oikein.',
notfound_adaptive_login: 'Kirjaudu sisään',
notfound_adaptive_registration_hint:
'Rekisteröityminen voi olla mahdollista organisaatiosta riippuen.',
notfound_adaptive_no_access_title: 'Sinulla ei ehkä ole pääsyä tälle sivulle',
notfound_adaptive_no_access:
'Tätä sivua ei ehkä ole olemassa, tai tililläsi ei ehkä ole pääsyä siihen. Jos seurasit linkkiä, tarkista, että se on oikein.',
notfound_adaptive_login_again: 'Kirjaudu uudelleen',
notfound_goto_home: 'Siirry etusivulle',
notfound_suggestions_title: 'Saatat etsiä',
unexpected_error_title: 'Tapahtui virhe',
@@ -99,9 +103,8 @@ export const fi: TranslationLanguage = {
pdf_page_of: '${1}/${2}',
pdf_mode_only_page: 'Vain tämä sivu',
pdf_mode_all: 'Kaikki sivut',
pdf_batch_range: 'Näytetään sivut ${1}–${2}/${3}.',
pdf_batch_previous: 'Edelliset ${1} sivua',
pdf_batch_next: 'Seuraavat ${1} sivua',
pdf_limit_reached: 'PDF-tiedostoa ei voitu luoda ${1} sivulle, luonti pysähtyi kohtaan ${2}.',
pdf_limit_reached_continue: 'Laajenna ${1} sivulla.',
more: 'Lisää',
link_tooltip_external_link: 'Ulkoinen linkki kohteeseen',
link_tooltip_email: 'Lähetä sähköpostia osoitteeseen',
+8 -5
View File
@@ -78,11 +78,15 @@ export const fr: TranslationLanguage = {
notfound_title: 'Page introuvable',
notfound_link: "Ce lien pointe vers une page qui a été supprimée ou n'existe plus.",
notfound: 'La page que vous cherchez n’existe pas.',
notfound_adaptive_title: 'Page inaccessible',
notfound_adaptive_title: 'Connectez-vous pour afficher cette page',
notfound_adaptive:
'Cette page existe peut-être, mais vous devez peut-être vous connecter pour y accéder.',
"Cette page peut nécessiter une connexion. Si vous avez suivi un lien, vérifiez qu'il est correct.",
notfound_adaptive_login: 'Se connecter',
notfound_adaptive_registration_hint: "L'inscription peut être disponible selon l'organisation.",
notfound_adaptive_no_access_title: "Vous n'avez peut-être pas accès à cette page",
notfound_adaptive_no_access:
"Cette page n'existe peut-être pas, ou votre compte n'y a peut-être pas accès. Si vous avez suivi un lien, vérifiez qu'il est correct.",
notfound_adaptive_login_again: 'Se reconnecter',
notfound_goto_home: "Aller à l'accueil",
notfound_suggestions_title: 'Vous cherchez peut-être',
unexpected_error_title: 'Erreur inattendue',
@@ -98,9 +102,8 @@ export const fr: TranslationLanguage = {
pdf_page_of: '${1} sur ${2}',
pdf_mode_only_page: 'Cette page uniquement',
pdf_mode_all: 'Toutes les pages',
pdf_batch_range: 'Pages ${1} à ${2} sur ${3}.',
pdf_batch_previous: '${1} pages précédentes',
pdf_batch_next: '${1} pages suivantes',
pdf_limit_reached: 'Impossible de générer le PDF pour ${1} pages, arrêté à ${2}.',
pdf_limit_reached_continue: 'Ajouter ${1} pages supplémentaires',
more: 'Plus',
link_tooltip_external_link: 'Lien externe vers',
link_tooltip_email: 'Envoyer un e-mail à',
+8 -5
View File
@@ -77,10 +77,14 @@ export const he: TranslationLanguage = {
notfound_title: 'הדף לא נמצא',
notfound_link: 'קישור זה מפנה לדף שהוסר או אינו קיים עוד.',
notfound: 'הדף שחיפשת אינו קיים.',
notfound_adaptive_title: 'הדף אינו זמין',
notfound_adaptive: 'ייתכן שהדף קיים, אך ייתכן שעליך להתחבר כדי לגשת אליו.',
notfound_adaptive_title: 'יש להתחבר כדי לצפות בדף זה',
notfound_adaptive: 'ייתכן שדף זה דורש התחברות. אם הגעת דרך קישור, יש לוודא שהוא נכון.',
notfound_adaptive_login: 'התחברות',
notfound_adaptive_registration_hint: 'ייתכן שההרשמה זמינה בהתאם לארגון.',
notfound_adaptive_no_access_title: 'ייתכן שאין לך גישה לדף זה',
notfound_adaptive_no_access:
'ייתכן שדף זה אינו קיים, או שלחשבון שלך אין גישה אליו. אם הגעת דרך קישור, יש לוודא שהוא נכון.',
notfound_adaptive_login_again: 'התחברות מחדש',
notfound_goto_home: 'מעבר לדף הבית',
notfound_suggestions_title: 'אולי אתה מחפש',
unexpected_error_title: 'אירעה שגיאה',
@@ -96,9 +100,8 @@ export const he: TranslationLanguage = {
pdf_page_of: '${1} מתוך ${2}',
pdf_mode_only_page: 'רק הדף הזה',
pdf_mode_all: 'כל הדפים',
pdf_batch_range: 'מוצגים דפים ${1}–${2} מתוך ${3}.',
pdf_batch_previous: '${1} הדפים הקודמים',
pdf_batch_next: '${1} הדפים הבאים',
pdf_limit_reached: 'לא ניתן ליצור PDF עבור ${1} דפים, היצירה נעצרה ב-${2}.',
pdf_limit_reached_continue: 'הרחבה עם עוד ${1} דפים.',
more: 'עוד',
link_tooltip_external_link: 'קישור חיצוני אל',
link_tooltip_email: 'שליחת אימייל אל',
+9 -5
View File
@@ -77,10 +77,15 @@ export const hi: TranslationLanguage = {
notfound_title: 'पृष्ठ नहीं मिला',
notfound_link: 'यह लिंक ऐसे पृष्ठ पर जाता है जिसे हटा दिया गया है या जो अब मौजूद नहीं है।',
notfound: 'आप जिस पृष्ठ को खोज रहे हैं वह मौजूद नहीं है।',
notfound_adaptive_title: 'पृष्ठ उपलब्ध नहीं',
notfound_adaptive: 'यह पृष्ठ मौजूद हो सकता है, लेकिन इसे देखने के लिए आपको लॉग इन करना पड़ सकता है।',
notfound_adaptive_title: 'यह पृष्ठ देखने के लिए लॉग इन करें',
notfound_adaptive:
'इस पृष्ठ के लिए लॉग इन करना आवश्यक हो सकता है। यदि आप किसी लिंक से आए हैं, तो जांच लें कि वह सही है।',
notfound_adaptive_login: 'लॉग इन करें',
notfound_adaptive_registration_hint: 'संगठन के आधार पर पंजीकरण उपलब्ध हो सकता है।',
notfound_adaptive_no_access_title: 'हो सकता है कि आपके पास इस पृष्ठ की पहुंच न हो',
notfound_adaptive_no_access:
'हो सकता है कि यह पृष्ठ मौजूद न हो, या आपके खाते के पास इसकी पहुंच न हो। यदि आप किसी लिंक से आए हैं, तो जांच लें कि वह सही है।',
notfound_adaptive_login_again: 'फिर से लॉग इन करें',
notfound_goto_home: 'मुखपृष्ठ पर जाएं',
notfound_suggestions_title: 'शायद आप यह ढूँढ रहे हैं',
unexpected_error_title: 'त्रुटि हुई',
@@ -96,9 +101,8 @@ export const hi: TranslationLanguage = {
pdf_page_of: '${1} में से ${2}',
pdf_mode_only_page: 'केवल यह पृष्ठ',
pdf_mode_all: 'सभी पृष्ठ',
pdf_batch_range: '${3} में से पृष्ठ ${1}–${2} दिखाए जा रहे हैं।',
pdf_batch_previous: 'पिछले ${1} पृष्ठ',
pdf_batch_next: 'अगले ${1} पृष्ठ',
pdf_limit_reached: '${1} पृष्ठों के लिए PDF नहीं बन सका, जनरेशन ${2} पर रुक गया।',
pdf_limit_reached_continue: '${1} और पृष्ठों के साथ बढ़ाएं।',
more: 'अधिक',
link_tooltip_external_link: 'बाहरी लिंक',
link_tooltip_email: 'ईमेल भेजें',
+9 -5
View File
@@ -77,11 +77,15 @@ export const hr: TranslationLanguage = {
notfound_title: 'Stranica nije pronađena',
notfound_link: 'Ova poveznica vodi na stranicu koja je uklonjena ili više ne postoji.',
notfound: 'Stranica koju tražite ne postoji.',
notfound_adaptive_title: 'Stranica nije dostupna',
notfound_adaptive_title: 'Prijavite se za prikaz ove stranice',
notfound_adaptive:
'Ova stranica možda postoji, ali možda se morate prijaviti da biste joj pristupili.',
'Ova stranica možda zahtijeva prijavu. Ako ste slijedili poveznicu, provjerite je li ispravna.',
notfound_adaptive_login: 'Prijava',
notfound_adaptive_registration_hint: 'Registracija može biti dostupna ovisno o organizaciji.',
notfound_adaptive_no_access_title: 'Možda nemate pristup ovoj stranici',
notfound_adaptive_no_access:
'Ova stranica možda ne postoji ili vaš račun nema pristup njoj. Ako ste slijedili poveznicu, provjerite je li ispravna.',
notfound_adaptive_login_again: 'Ponovna prijava',
notfound_goto_home: 'Idi na početnu stranicu',
notfound_suggestions_title: 'Možda tražite',
unexpected_error_title: 'Došlo je do pogreške',
@@ -97,9 +101,9 @@ export const hr: TranslationLanguage = {
pdf_page_of: '${1} od ${2}',
pdf_mode_only_page: 'Samo ova stranica',
pdf_mode_all: 'Sve stranice',
pdf_batch_range: 'Prikazane stranice ${1}–${2} od ${3}.',
pdf_batch_previous: 'Prethodnih ${1} stranica',
pdf_batch_next: 'Sljedećih ${1} stranica',
pdf_limit_reached:
'Nije moguće generirati PDF za ${1} stranica, generiranje je zaustavljeno na ${2}.',
pdf_limit_reached_continue: 'Proširi za još ${1} stranica.',
more: 'Više',
link_tooltip_external_link: 'Vanjska poveznica na',
link_tooltip_email: 'Pošalji e-poštu na',
+10 -5
View File
@@ -78,10 +78,15 @@ export const hu: TranslationLanguage = {
notfound_title: 'Az oldal nem található',
notfound_link: 'Ez a hivatkozás egy eltávolított vagy már nem létező oldalra mutat.',
notfound: 'A keresett oldal nem létezik.',
notfound_adaptive_title: 'Az oldal nem érhető el',
notfound_adaptive: 'Ez az oldal létezhet, de a hozzáféréshez lehet, hogy be kell jelentkeznie.',
notfound_adaptive_title: 'Jelentkezzen be az oldal megtekintéséhez',
notfound_adaptive:
'Ehhez az oldalhoz bejelentkezés szükséges lehet. Ha egy hivatkozást követett, ellenőrizze, hogy helyes-e.',
notfound_adaptive_login: 'Bejelentkezés',
notfound_adaptive_registration_hint: 'A regisztráció a szervezettől függően elérhető lehet.',
notfound_adaptive_no_access_title: 'Lehet, hogy nincs hozzáférése ehhez az oldalhoz',
notfound_adaptive_no_access:
'Lehet, hogy ez az oldal nem létezik, vagy a fiókja nem fér hozzá. Ha egy hivatkozást követett, ellenőrizze, hogy helyes-e.',
notfound_adaptive_login_again: 'Újbóli bejelentkezés',
notfound_goto_home: 'Ugrás a kezdőlapra',
notfound_suggestions_title: 'Talán ezt keresi',
unexpected_error_title: 'Hiba történt',
@@ -97,9 +102,9 @@ export const hu: TranslationLanguage = {
pdf_page_of: '${1} / ${2}',
pdf_mode_only_page: 'Csak ez az oldal',
pdf_mode_all: 'Minden oldal',
pdf_batch_range: '${1}–${2}. oldal, összesen ${3}.',
pdf_batch_previous: 'Előző ${1} oldal',
pdf_batch_next: 'Következő ${1} oldal',
pdf_limit_reached:
'Nem sikerült PDF-et létrehozni ${1} oldalhoz, a létrehozás itt megállt: ${2}.',
pdf_limit_reached_continue: 'Bővítés további ${1} oldallal.',
more: 'Továbbiak',
link_tooltip_external_link: 'Külső hivatkozás ide:',
link_tooltip_email: 'E-mail küldése ide:',
+8 -5
View File
@@ -77,11 +77,15 @@ export const id: TranslationLanguage = {
notfound_title: 'Halaman tidak ditemukan',
notfound_link: 'Tautan ini mengarah ke halaman yang telah dihapus atau sudah tidak ada.',
notfound: 'Halaman yang Anda cari tidak ada.',
notfound_adaptive_title: 'Halaman tidak tersedia',
notfound_adaptive_title: 'Masuk untuk melihat halaman ini',
notfound_adaptive:
'Halaman ini mungkin ada, tetapi Anda mungkin perlu masuk untuk mengaksesnya.',
'Halaman ini mungkin mengharuskan Anda masuk. Jika Anda mengikuti tautan, periksa apakah tautan tersebut benar.',
notfound_adaptive_login: 'Masuk',
notfound_adaptive_registration_hint: 'Pendaftaran mungkin tersedia tergantung pada organisasi.',
notfound_adaptive_no_access_title: 'Anda mungkin tidak memiliki akses ke halaman ini',
notfound_adaptive_no_access:
'Halaman ini mungkin tidak ada, atau akun Anda mungkin tidak memiliki akses ke halaman ini. Jika Anda mengikuti tautan, periksa apakah tautan tersebut benar.',
notfound_adaptive_login_again: 'Masuk lagi',
notfound_goto_home: 'Buka beranda',
notfound_suggestions_title: 'Mungkin Anda mencari',
unexpected_error_title: 'Terjadi kesalahan',
@@ -97,9 +101,8 @@ export const id: TranslationLanguage = {
pdf_page_of: '${1} dari ${2}',
pdf_mode_only_page: 'Hanya halaman ini',
pdf_mode_all: 'Semua halaman',
pdf_batch_range: 'Menampilkan halaman ${1}–${2} dari ${3}.',
pdf_batch_previous: '${1} halaman sebelumnya',
pdf_batch_next: '${1} halaman berikutnya',
pdf_limit_reached: 'Tidak dapat membuat PDF untuk ${1} halaman, pembuatan berhenti di ${2}.',
pdf_limit_reached_continue: 'Perluas dengan ${1} halaman lagi.',
more: 'Lainnya',
link_tooltip_external_link: 'Tautan eksternal ke',
link_tooltip_email: 'Kirim email ke',
+9 -5
View File
@@ -79,12 +79,16 @@ export const it: TranslationLanguage = {
notfound_title: 'Pagina non trovata',
notfound_link: 'Questo link punta a una pagina che è stata rimossa o non esiste più.',
notfound: 'La pagina che cerchi non esiste.',
notfound_adaptive_title: 'Pagina non disponibile',
notfound_adaptive_title: 'Accedi per visualizzare questa pagina',
notfound_adaptive:
"Questa pagina potrebbe esistere, ma potrebbe essere necessario effettuare l'accesso per visualizzarla.",
"Questa pagina potrebbe richiedere l'accesso. Se hai seguito un link, verifica che sia corretto.",
notfound_adaptive_login: 'Accedi',
notfound_adaptive_registration_hint:
"La registrazione potrebbe essere disponibile a seconda dell'organizzazione.",
notfound_adaptive_no_access_title: 'Potresti non avere accesso a questa pagina',
notfound_adaptive_no_access:
'Questa pagina potrebbe non esistere, oppure il tuo account potrebbe non avervi accesso. Se hai seguito un link, verifica che sia corretto.',
notfound_adaptive_login_again: 'Accedi di nuovo',
notfound_goto_home: 'Vai alla home',
notfound_suggestions_title: 'Forse stai cercando',
unexpected_error_title: 'Si è verificato un errore',
@@ -100,9 +104,9 @@ export const it: TranslationLanguage = {
pdf_page_of: '${1} di ${2}',
pdf_mode_only_page: 'Solo questa pagina',
pdf_mode_all: 'Tutte le pagine',
pdf_batch_range: 'Pagine ${1}–${2} di ${3}.',
pdf_batch_previous: '${1} pagine precedenti',
pdf_batch_next: '${1} pagine successive',
pdf_limit_reached:
'Impossibile generare il PDF per ${1} pagine, la generazione si è fermata a ${2}.',
pdf_limit_reached_continue: 'Estendi con altre ${1} pagine.',
more: 'Altro',
link_tooltip_external_link: 'Link esterno a',
link_tooltip_email: "Invia un'email a",
+8 -5
View File
@@ -78,11 +78,15 @@ export const ja: TranslationLanguage = {
notfound_title: 'ページが見つかりません',
notfound_link: 'このリンクは、削除されたか、もはや存在しないページを指しています。',
notfound: 'お探しのページは存在しません。',
notfound_adaptive_title: 'ページにアクセスできません',
notfound_adaptive_title: 'このページを表示するにはログインしてください',
notfound_adaptive:
'このページは存在する可能性がありますが、アクセスするにはログインが必要な場合があります。',
'このページの閲覧にはログインが必要な場合があります。リンクからアクセスした場合は、リンクが正しいか確認してください。',
notfound_adaptive_login: 'ログイン',
notfound_adaptive_registration_hint: '組織によっては登録が可能な場合があります。',
notfound_adaptive_no_access_title: 'このページへのアクセス権がない可能性があります',
notfound_adaptive_no_access:
'このページが存在しないか、お使いのアカウントにアクセス権がない可能性があります。リンクからアクセスした場合は、リンクが正しいか確認してください。',
notfound_adaptive_login_again: '再ログイン',
notfound_goto_home: 'ホームへ移動',
notfound_suggestions_title: 'お探しのページはこちらですか',
unexpected_error_title: 'エラーが発生しました',
@@ -98,9 +102,8 @@ export const ja: TranslationLanguage = {
pdf_page_of: '${1} / ${2}',
pdf_mode_only_page: 'このページのみ',
pdf_mode_all: '全てのページ',
pdf_batch_range: '${3}ページ中 ${1}–${2}ページを表示しています。',
pdf_batch_previous: '前の${1}ページ',
pdf_batch_next: '次の${1}ページ',
pdf_limit_reached: '${1}ページのPDFを生成できませんでした、${2}で生成が停止しました。',
pdf_limit_reached_continue: 'さらに${1}ページで拡張',
more: 'もっと見る',
link_tooltip_external_link: '外部リンクへ',
link_tooltip_email: 'メールを送信',
+9 -5
View File
@@ -78,10 +78,15 @@ export const ko: TranslationLanguage = {
notfound_title: '페이지를 찾을 수 없음',
notfound_link: '이 링크는 삭제되었거나 더 이상 존재하지 않는 페이지를 가리킵니다.',
notfound: '찾으시는 페이지가 존재하지 않습니다.',
notfound_adaptive_title: '페이지에 접근할 수 없음',
notfound_adaptive: '이 페이지는 존재할 수 있지만, 접근하려면 로그인해야 할 수 있습니다.',
notfound_adaptive_title: '이 페이지를 보려면 로그인하세요',
notfound_adaptive:
'이 페이지는 로그인이 필요할 수 있습니다. 링크를 통해 접속했다면 링크가 올바른지 확인하세요.',
notfound_adaptive_login: '로그인',
notfound_adaptive_registration_hint: '조직에 따라 등록이 가능할 수 있습니다.',
notfound_adaptive_no_access_title: '이 페이지에 대한 접근 권한이 없을 수 있습니다',
notfound_adaptive_no_access:
'이 페이지가 존재하지 않거나 계정에 이 페이지에 대한 접근 권한이 없을 수 있습니다. 링크를 통해 접속했다면 링크가 올바른지 확인하세요.',
notfound_adaptive_login_again: '다시 로그인',
notfound_goto_home: '홈으로 이동',
notfound_suggestions_title: '찾고 계신 내용일 수 있어요',
unexpected_error_title: '오류가 발생했습니다',
@@ -97,9 +102,8 @@ export const ko: TranslationLanguage = {
pdf_page_of: '${1} / ${2}',
pdf_mode_only_page: '이 페이지만',
pdf_mode_all: '모든 페이지',
pdf_batch_range: '전체 ${3}페이지 중 ${1}–${2}페이지를 표시하고 있습니다.',
pdf_batch_previous: '이전 ${1}페이지',
pdf_batch_next: '다음 ${1}페이지',
pdf_limit_reached: '${1}페이지에 대한 PDF를 생성할 수 없어 ${2}에서 생성이 중지되었습니다.',
pdf_limit_reached_continue: '${1}페이지 더 확장하기.',
more: '더 보기',
link_tooltip_external_link: '외부 링크',
link_tooltip_email: '이메일 보내기',
+8 -5
View File
@@ -77,12 +77,16 @@ export const lt: TranslationLanguage = {
notfound_title: 'Puslapis nerastas',
notfound_link: 'Ši nuoroda veda į puslapį, kuris buvo pašalintas arba nebeegzistuoja.',
notfound: 'Puslapis, kurio ieškote, neegzistuoja.',
notfound_adaptive_title: 'Puslapis nepasiekiamas',
notfound_adaptive_title: 'Prisijunkite, kad peržiūrėtumėte šį puslapį',
notfound_adaptive:
'Šis puslapis gali egzistuoti, bet norint jį pasiekti gali reikėti prisijungti.',
'Šiam puslapiui gali reikėti prisijungti. Jei sekėte nuoroda, patikrinkite, ar ji teisinga.',
notfound_adaptive_login: 'Prisijungti',
notfound_adaptive_registration_hint:
'Registracija gali būti galima priklausomai nuo organizacijos.',
notfound_adaptive_no_access_title: 'Galbūt neturite prieigos prie šio puslapio',
notfound_adaptive_no_access:
'Šis puslapis gali neegzistuoti arba jūsų paskyra gali neturėti prieigos prie jo. Jei sekėte nuoroda, patikrinkite, ar ji teisinga.',
notfound_adaptive_login_again: 'Prisijungti iš naujo',
notfound_goto_home: 'Eiti į pagrindinį puslapį',
notfound_suggestions_title: 'Galbūt ieškote',
unexpected_error_title: 'Įvyko klaida',
@@ -98,9 +102,8 @@ export const lt: TranslationLanguage = {
pdf_page_of: '${1} iš ${2}',
pdf_mode_only_page: 'Tik šis puslapis',
pdf_mode_all: 'Visi puslapiai',
pdf_batch_range: 'Rodomi puslapiai ${1}–${2} iš ${3}.',
pdf_batch_previous: 'Ankstesni ${1} puslapiai',
pdf_batch_next: 'Kiti ${1} puslapiai',
pdf_limit_reached: 'Nepavyko sugeneruoti PDF ${1} puslapiams, generavimas sustojo ties ${2}.',
pdf_limit_reached_continue: 'Išplėsti dar ${1} puslapiais.',
more: 'Daugiau',
link_tooltip_external_link: 'Išorinė nuoroda į',
link_tooltip_email: 'Siųsti el. laišką į',
+9 -5
View File
@@ -77,10 +77,15 @@ export const lv: TranslationLanguage = {
notfound_title: 'Lapa nav atrasta',
notfound_link: 'Šī saite norāda uz lapu, kas ir noņemta vai vairs nepastāv.',
notfound: 'Meklētā lapa nepastāv.',
notfound_adaptive_title: 'Lapa nav pieejama',
notfound_adaptive: 'Šī lapa var pastāvēt, bet, iespējams, jums jāpierakstās, lai tai piekļūtu.',
notfound_adaptive_title: 'Pierakstieties, lai skatītu šo lapu',
notfound_adaptive:
'Šai lapai, iespējams, nepieciešams pierakstīties. Ja sekojāt saitei, pārbaudiet, vai tā ir pareiza.',
notfound_adaptive_login: 'Pierakstīties',
notfound_adaptive_registration_hint: 'Reģistrācija var būt pieejama atkarībā no organizācijas.',
notfound_adaptive_no_access_title: 'Iespējams, jums nav piekļuves šai lapai',
notfound_adaptive_no_access:
'Šī lapa, iespējams, neeksistē, vai arī jūsu kontam nav piekļuves tai. Ja sekojāt saitei, pārbaudiet, vai tā ir pareiza.',
notfound_adaptive_login_again: 'Pierakstīties vēlreiz',
notfound_goto_home: 'Doties uz sākumlapu',
notfound_suggestions_title: 'Iespējams, meklējat',
unexpected_error_title: 'Radās kļūda',
@@ -96,9 +101,8 @@ export const lv: TranslationLanguage = {
pdf_page_of: '${1} no ${2}',
pdf_mode_only_page: 'Tikai šī lapa',
pdf_mode_all: 'Visas lapas',
pdf_batch_range: 'Rāda lapas ${1}–${2} no ${3}.',
pdf_batch_previous: 'Iepriekšējās ${1} lapas',
pdf_batch_next: 'Nākamās ${1} lapas',
pdf_limit_reached: 'Neizdevās ģenerēt PDF ${1} lapām, ģenerēšana apstājās pie ${2}.',
pdf_limit_reached_continue: 'Paplašināt ar vēl ${1} lapām.',
more: 'Vairāk',
link_tooltip_external_link: 'Ārēja saite uz',
link_tooltip_email: 'Sūtīt e-pastu uz',
+8 -5
View File
@@ -77,11 +77,15 @@ export const ms: TranslationLanguage = {
notfound_title: 'Halaman tidak ditemui',
notfound_link: 'Pautan ini menghala ke halaman yang telah dialih keluar atau tidak lagi wujud.',
notfound: 'Halaman yang anda cari tidak wujud.',
notfound_adaptive_title: 'Halaman tidak tersedia',
notfound_adaptive_title: 'Log masuk untuk melihat halaman ini',
notfound_adaptive:
'Halaman ini mungkin wujud, tetapi anda mungkin perlu log masuk untuk mengaksesnya.',
'Halaman ini mungkin memerlukan anda log masuk. Jika anda mengikuti pautan, semak sama ada pautan itu betul.',
notfound_adaptive_login: 'Log masuk',
notfound_adaptive_registration_hint: 'Pendaftaran mungkin tersedia bergantung pada organisasi.',
notfound_adaptive_no_access_title: 'Anda mungkin tidak mempunyai akses ke halaman ini',
notfound_adaptive_no_access:
'Halaman ini mungkin tidak wujud, atau akaun anda mungkin tidak mempunyai akses kepadanya. Jika anda mengikuti pautan, semak sama ada pautan itu betul.',
notfound_adaptive_login_again: 'Log masuk semula',
notfound_goto_home: 'Pergi ke halaman utama',
notfound_suggestions_title: 'Mungkin anda mencari',
unexpected_error_title: 'Ralat berlaku',
@@ -97,9 +101,8 @@ export const ms: TranslationLanguage = {
pdf_page_of: '${1} daripada ${2}',
pdf_mode_only_page: 'Halaman ini sahaja',
pdf_mode_all: 'Semua halaman',
pdf_batch_range: 'Memaparkan halaman ${1}–${2} daripada ${3}.',
pdf_batch_previous: '${1} halaman sebelumnya',
pdf_batch_next: '${1} halaman seterusnya',
pdf_limit_reached: 'Tidak dapat menjana PDF untuk ${1} halaman, penjanaan berhenti pada ${2}.',
pdf_limit_reached_continue: 'Lanjutkan dengan ${1} halaman lagi.',
more: 'Lagi',
link_tooltip_external_link: 'Pautan luaran ke',
link_tooltip_email: 'Hantar e-mel kepada',
+8 -5
View File
@@ -79,12 +79,16 @@ export const nl: TranslationLanguage = {
notfound_title: 'Pagina niet gevonden',
notfound_link: 'Deze link verwijst naar een pagina die is verwijderd of niet meer bestaat.',
notfound: 'De pagina die je zoekt, bestaat niet.',
notfound_adaptive_title: 'Pagina niet beschikbaar',
notfound_adaptive_title: 'Log in om deze pagina te bekijken',
notfound_adaptive:
'Deze pagina bestaat mogelijk, maar je moet mogelijk inloggen om toegang te krijgen.',
'Voor deze pagina moet je mogelijk inloggen. Als je een link hebt gevolgd, controleer dan of deze klopt.',
notfound_adaptive_login: 'Inloggen',
notfound_adaptive_registration_hint:
'Registratie is mogelijk beschikbaar, afhankelijk van de organisatie.',
notfound_adaptive_no_access_title: 'Je hebt mogelijk geen toegang tot deze pagina',
notfound_adaptive_no_access:
'Deze pagina bestaat mogelijk niet, of je account heeft er geen toegang toe. Als je een link hebt gevolgd, controleer dan of deze klopt.',
notfound_adaptive_login_again: 'Opnieuw inloggen',
notfound_goto_home: 'Naar startpagina',
notfound_suggestions_title: 'Misschien zoek je',
unexpected_error_title: 'Er is een fout opgetreden',
@@ -100,9 +104,8 @@ export const nl: TranslationLanguage = {
pdf_page_of: '${1} van ${2}',
pdf_mode_only_page: 'Alleen deze pagina',
pdf_mode_all: "Alle pagina's",
pdf_batch_range: "Pagina's ${1}–${2} van ${3}.",
pdf_batch_previous: "Vorige ${1} pagina's",
pdf_batch_next: "Volgende ${1} pagina's",
pdf_limit_reached: "Kon de PDF niet genereren voor ${1} pagina's, generatie gestopt bij ${2}.",
pdf_limit_reached_continue: "Verleng met ${1} extra pagina's.",
more: 'Meer',
link_tooltip_external_link: 'Externe link naar',
link_tooltip_email: 'E-mail versturen naar',
+9 -5
View File
@@ -79,11 +79,16 @@ export const no: TranslationLanguage = {
notfound_link:
'Denne lenken peker til en side som har blitt fjernet eller ikke lenger eksisterer.',
notfound: 'Siden du leter etter eksisterer ikke.',
notfound_adaptive_title: 'Siden er ikke tilgjengelig',
notfound_adaptive: 'Denne siden kan finnes, men du må kanskje logge inn for å få tilgang.',
notfound_adaptive_title: 'Logg inn for å se denne siden',
notfound_adaptive:
'Denne siden kan kreve at du logger inn. Hvis du fulgte en lenke, sjekk at den er riktig.',
notfound_adaptive_login: 'Logg inn',
notfound_adaptive_registration_hint:
'Registrering kan være tilgjengelig avhengig av organisasjonen.',
notfound_adaptive_no_access_title: 'Du har kanskje ikke tilgang til denne siden',
notfound_adaptive_no_access:
'Denne siden finnes kanskje ikke, eller kontoen din har kanskje ikke tilgang til den. Hvis du fulgte en lenke, sjekk at den er riktig.',
notfound_adaptive_login_again: 'Logg inn på nytt',
notfound_goto_home: 'Gå til forsiden',
notfound_suggestions_title: 'Kanskje du leter etter',
unexpected_error_title: 'En feil oppstod',
@@ -99,9 +104,8 @@ export const no: TranslationLanguage = {
pdf_page_of: '${1} av ${2}',
pdf_mode_only_page: 'Kun denne siden',
pdf_mode_all: 'Alle sider',
pdf_batch_range: 'Viser sider ${1}–${2} av ${3}.',
pdf_batch_previous: 'Forrige ${1} sider',
pdf_batch_next: 'Neste ${1} sider',
pdf_limit_reached: 'Kunne ikke generere PDF for ${1} sider, generering stoppet ved ${2}.',
pdf_limit_reached_continue: 'Utvid med ${1} flere sider.',
more: 'Mer',
link_tooltip_external_link: 'Ekstern lenke til',
link_tooltip_email: 'Send e-post til',
+10 -5
View File
@@ -77,11 +77,16 @@ export const pl: TranslationLanguage = {
notfound_title: 'Nie znaleziono strony',
notfound_link: 'Ten link prowadzi do strony, która została usunięta lub już nie istnieje.',
notfound: 'Strona, której szukasz, nie istnieje.',
notfound_adaptive_title: 'Strona niedostępna',
notfound_adaptive: 'Ta strona może istnieć, ale dostęp do niej może wymagać zalogowania.',
notfound_adaptive_title: 'Zaloguj się, aby wyświetlić tę stronę',
notfound_adaptive:
'Ta strona może wymagać zalogowania. Jeśli przechodzisz z linku, sprawdź, czy jest poprawny.',
notfound_adaptive_login: 'Zaloguj się',
notfound_adaptive_registration_hint:
'Rejestracja może być dostępna w zależności od organizacji.',
notfound_adaptive_no_access_title: 'Możesz nie mieć dostępu do tej strony',
notfound_adaptive_no_access:
'Ta strona może nie istnieć lub Twoje konto może nie mieć do niej dostępu. Jeśli przechodzisz z linku, sprawdź, czy jest poprawny.',
notfound_adaptive_login_again: 'Zaloguj się ponownie',
notfound_goto_home: 'Przejdź do strony głównej',
notfound_suggestions_title: 'Być może szukasz',
unexpected_error_title: 'Wystąpił błąd',
@@ -97,9 +102,9 @@ export const pl: TranslationLanguage = {
pdf_page_of: '${1} z ${2}',
pdf_mode_only_page: 'Tylko ta strona',
pdf_mode_all: 'Wszystkie strony',
pdf_batch_range: 'Strony ${1}–${2} z ${3}.',
pdf_batch_previous: 'Poprzednie ${1} stron',
pdf_batch_next: 'Następne ${1} stron',
pdf_limit_reached:
'Nie udało się wygenerować PDF dla ${1} stron, generowanie zatrzymało się na ${2}.',
pdf_limit_reached_continue: 'Rozszerz o kolejne ${1} stron.',
more: 'Więcej',
link_tooltip_external_link: 'Link zewnętrzny do',
link_tooltip_email: 'Wyślij e-mail do',
@@ -79,12 +79,16 @@ export const pt_br: TranslationLanguage = {
notfound_title: 'Página não encontrada',
notfound_link: 'Este link aponta para uma página que foi removida ou não existe mais.',
notfound: 'A página que você está procurando não existe.',
notfound_adaptive_title: 'Página indisponível',
notfound_adaptive_title: 'Faça login para ver esta página',
notfound_adaptive:
'Esta página pode existir, mas talvez você precise fazer login para acessá-la.',
'Esta página pode exigir login. Se você seguiu um link, verifique se ele está correto.',
notfound_adaptive_login: 'Fazer login',
notfound_adaptive_registration_hint:
'O registro pode estar disponível dependendo da organização.',
notfound_adaptive_no_access_title: 'Talvez você não tenha acesso a esta página',
notfound_adaptive_no_access:
'Esta página pode não existir ou sua conta pode não ter acesso a ela. Se você seguiu um link, verifique se ele está correto.',
notfound_adaptive_login_again: 'Fazer login novamente',
notfound_goto_home: 'Ir para a página inicial',
notfound_suggestions_title: 'Você pode estar procurando por',
unexpected_error_title: 'Aconteceu um erro',
@@ -101,9 +105,9 @@ export const pt_br: TranslationLanguage = {
pdf_page_of: '${1} de ${2}',
pdf_mode_only_page: 'Somente esta página',
pdf_mode_all: 'Todas as páginas',
pdf_batch_range: 'Mostrando as páginas ${1}–${2} de ${3}.',
pdf_batch_previous: '${1} páginas anteriores',
pdf_batch_next: 'Próximas ${1} páginas',
pdf_limit_reached:
'Não foi possível gerar o PDF para ${1} páginas, a geração foi interrompida em ${2}.',
pdf_limit_reached_continue: 'Estender com mais ${1} páginas.',
more: 'Mais',
link_tooltip_external_link: 'Link externo para',
link_tooltip_email: 'Enviar e-mail para',
+8 -5
View File
@@ -78,12 +78,16 @@ export const pt: TranslationLanguage = {
notfound_title: 'Página não encontrada',
notfound_link: 'Esta ligação aponta para uma página que foi removida ou já não existe.',
notfound: 'A página que procura não existe.',
notfound_adaptive_title: 'Página indisponível',
notfound_adaptive_title: 'Inicie sessão para ver esta página',
notfound_adaptive:
'Esta página pode existir, mas talvez tenha de iniciar sessão para lhe aceder.',
'Esta página pode exigir que inicie sessão. Se seguiu uma ligação, verifique se está correta.',
notfound_adaptive_login: 'Iniciar sessão',
notfound_adaptive_registration_hint:
'O registo pode estar disponível dependendo da organização.',
notfound_adaptive_no_access_title: 'Pode não ter acesso a esta página',
notfound_adaptive_no_access:
'Esta página pode não existir ou a sua conta pode não ter acesso à mesma. Se seguiu uma ligação, verifique se está correta.',
notfound_adaptive_login_again: 'Iniciar sessão novamente',
notfound_goto_home: 'Ir para a página inicial',
notfound_suggestions_title: 'Talvez esteja à procura de',
unexpected_error_title: 'Ocorreu um erro',
@@ -99,9 +103,8 @@ export const pt: TranslationLanguage = {
pdf_page_of: '${1} de ${2}',
pdf_mode_only_page: 'Apenas esta página',
pdf_mode_all: 'Todas as páginas',
pdf_batch_range: 'A mostrar as páginas ${1}–${2} de ${3}.',
pdf_batch_previous: '${1} páginas anteriores',
pdf_batch_next: '${1} páginas seguintes',
pdf_limit_reached: 'Não foi possível gerar o PDF para ${1} páginas; a geração parou em ${2}.',
pdf_limit_reached_continue: 'Expandir com mais ${1} páginas.',
more: 'Mais',
link_tooltip_external_link: 'Ligação externa para',
link_tooltip_email: 'Enviar e-mail para',
+9 -5
View File
@@ -78,12 +78,16 @@ export const ro: TranslationLanguage = {
notfound_title: 'Pagina nu a fost găsită',
notfound_link: 'Acest link indică o pagină care a fost eliminată sau nu mai există.',
notfound: 'Pagina pe care o cauți nu există.',
notfound_adaptive_title: 'Pagina nu este disponibilă',
notfound_adaptive_title: 'Autentifică-te pentru a vedea această pagină',
notfound_adaptive:
'Această pagină poate exista, dar este posibil să trebuiască să te autentifici pentru a o accesa.',
'Această pagină poate necesita autentificare. Dacă ai urmat un link, verifică dacă este corect.',
notfound_adaptive_login: 'Autentificare',
notfound_adaptive_registration_hint:
'Înregistrarea poate fi disponibilă în funcție de organizație.',
notfound_adaptive_no_access_title: 'Este posibil să nu ai acces la această pagină',
notfound_adaptive_no_access:
'Este posibil ca această pagină să nu existe sau contul tău să nu aibă acces la ea. Dacă ai urmat un link, verifică dacă este corect.',
notfound_adaptive_login_again: 'Reautentificare',
notfound_goto_home: 'Mergi la pagina principală',
notfound_suggestions_title: 'Poate cauți',
unexpected_error_title: 'A apărut o eroare',
@@ -100,9 +104,9 @@ export const ro: TranslationLanguage = {
pdf_page_of: '${1} din ${2}',
pdf_mode_only_page: 'Doar această pagină',
pdf_mode_all: 'Toate paginile',
pdf_batch_range: 'Se afișează paginile ${1}–${2} din ${3}.',
pdf_batch_previous: '${1} pagini anterioare',
pdf_batch_next: 'Următoarele ${1} pagini',
pdf_limit_reached:
'Nu s-a putut genera PDF-ul pentru ${1} pagini, generarea s-a oprit la ${2}.',
pdf_limit_reached_continue: 'Extinde cu încă ${1} pagini.',
more: 'Mai multe',
link_tooltip_external_link: 'Link extern către',
link_tooltip_email: 'Trimite e-mail către',
+9 -5
View File
@@ -79,12 +79,16 @@ export const ru: TranslationLanguage = {
notfound_title: 'Страница не найдена',
notfound_link: 'Эта ссылка ведёт на страницу, которая была удалена или больше не существует.',
notfound: 'Страница, которую вы ищете, не существует.',
notfound_adaptive_title: 'Страница недоступна',
notfound_adaptive_title: 'Войдите, чтобы просмотреть эту страницу',
notfound_adaptive:
'Эта страница может существовать, но для доступа к ней может потребоваться вход.',
'Для просмотра этой страницы может потребоваться вход. Если вы перешли по ссылке, проверьте, что она верна.',
notfound_adaptive_login: 'Войти',
notfound_adaptive_registration_hint:
'Регистрация может быть доступна в зависимости от организации.',
notfound_adaptive_no_access_title: 'Возможно, у вас нет доступа к этой странице',
notfound_adaptive_no_access:
'Возможно, эта страница не существует или у вашей учётной записи нет к ней доступа. Если вы перешли по ссылке, проверьте, что она верна.',
notfound_adaptive_login_again: 'Войти снова',
notfound_goto_home: 'Перейти на главную',
notfound_suggestions_title: 'Возможно, вы ищете',
unexpected_error_title: 'Произошла ошибка',
@@ -100,9 +104,9 @@ export const ru: TranslationLanguage = {
pdf_page_of: '${1} из ${2}',
pdf_mode_only_page: 'Только эта страница',
pdf_mode_all: 'Все страницы',
pdf_batch_range: 'Страницы ${1}–${2} из ${3}.',
pdf_batch_previous: 'Предыдущие ${1} страниц',
pdf_batch_next: 'Следующие ${1} страниц',
pdf_limit_reached:
'Не удалось создать PDF-файл для ${1} страниц, генерация остановлена на ${2}.',
pdf_limit_reached_continue: 'Расширьте ещё на ${1} страниц.',
more: 'Ещё',
link_tooltip_external_link: 'Внешняя ссылка на',
link_tooltip_email: 'Отправить письмо на',
+9 -5
View File
@@ -78,12 +78,16 @@ export const sk: TranslationLanguage = {
notfound_title: 'Stránka sa nenašla',
notfound_link: 'Tento odkaz smeruje na stránku, ktorá bola odstránená alebo už neexistuje.',
notfound: 'Stránka, ktorú hľadáte, neexistuje.',
notfound_adaptive_title: 'Stránka nie je dostupná',
notfound_adaptive_title: 'Na zobrazenie tejto stránky sa prihláste',
notfound_adaptive:
'Táto stránka môže existovať, ale na prístup sa možno budete musieť prihlásiť.',
'Táto stránka môže vyžadovať prihlásenie. Ak ste prešli z odkazu, skontrolujte, či je správny.',
notfound_adaptive_login: 'Prihlásiť sa',
notfound_adaptive_registration_hint:
'Registrácia môže byť dostupná v závislosti od organizácie.',
notfound_adaptive_no_access_title: 'K tejto stránke možno nemáte prístup',
notfound_adaptive_no_access:
'Táto stránka možno neexistuje alebo k nej váš účet nemá prístup. Ak ste prešli z odkazu, skontrolujte, či je správny.',
notfound_adaptive_login_again: 'Prihlásiť sa znova',
notfound_goto_home: 'Prejsť na domovskú stránku',
notfound_suggestions_title: 'Možno hľadáte',
unexpected_error_title: 'Vyskytla sa chyba',
@@ -99,9 +103,9 @@ export const sk: TranslationLanguage = {
pdf_page_of: '${1} z ${2}',
pdf_mode_only_page: 'Iba táto stránka',
pdf_mode_all: 'Všetky stránky',
pdf_batch_range: 'Zobrazené stránky ${1}–${2} z ${3}.',
pdf_batch_previous: 'Predchádzajúcich ${1} stránok',
pdf_batch_next: 'Ďalších ${1} stránok',
pdf_limit_reached:
'Nepodarilo sa vygenerovať PDF pre ${1} stránok, generovanie sa zastavilo na ${2}.',
pdf_limit_reached_continue: 'Rozšíriť o ďalších ${1} stránok.',
more: 'Viac',
link_tooltip_external_link: 'Externý odkaz na',
link_tooltip_email: 'Odoslať e-mail na',
+10 -5
View File
@@ -78,10 +78,15 @@ export const sl: TranslationLanguage = {
notfound_title: 'Strani ni bilo mogoče najti',
notfound_link: 'Ta povezava kaže na stran, ki je bila odstranjena ali ne obstaja več.',
notfound: 'Stran, ki jo iščete, ne obstaja.',
notfound_adaptive_title: 'Stran ni na voljo',
notfound_adaptive: 'Ta stran morda obstaja, vendar se boste za dostop morda morali prijaviti.',
notfound_adaptive_title: 'Za ogled te strani se prijavite',
notfound_adaptive:
'Ta stran morda zahteva prijavo. Če ste sledili povezavi, preverite, ali je pravilna.',
notfound_adaptive_login: 'Prijava',
notfound_adaptive_registration_hint: 'Registracija je morda na voljo, odvisno od organizacije.',
notfound_adaptive_no_access_title: 'Morda nimate dostopa do te strani',
notfound_adaptive_no_access:
'Ta stran morda ne obstaja ali pa vaš račun nima dostopa do nje. Če ste sledili povezavi, preverite, ali je pravilna.',
notfound_adaptive_login_again: 'Ponovna prijava',
notfound_goto_home: 'Pojdi na domačo stran',
notfound_suggestions_title: 'Morda iščete',
unexpected_error_title: 'Prišlo je do napake',
@@ -97,9 +102,9 @@ export const sl: TranslationLanguage = {
pdf_page_of: '${1} od ${2}',
pdf_mode_only_page: 'Samo ta stran',
pdf_mode_all: 'Vse strani',
pdf_batch_range: 'Prikazane strani ${1}–${2} od ${3}.',
pdf_batch_previous: 'Prejšnjih ${1} strani',
pdf_batch_next: 'Naslednjih ${1} strani',
pdf_limit_reached:
'PDF-ja ni bilo mogoče ustvariti za ${1} strani, ustvarjanje se je ustavilo pri ${2}.',
pdf_limit_reached_continue: 'Razširi še za ${1} strani.',
more: 'Več',
link_tooltip_external_link: 'Zunanja povezava do',
link_tooltip_email: 'Pošlji e-pošto na',
+10 -5
View File
@@ -77,11 +77,16 @@ export const sv: TranslationLanguage = {
notfound_title: 'Sidan hittades inte',
notfound_link: 'Den här länken pekar på en sida som har tagits bort eller inte längre finns.',
notfound: 'Sidan du letar efter finns inte.',
notfound_adaptive_title: 'Sidan är inte tillgänglig',
notfound_adaptive: 'Sidan kan finnas, men du kan behöva logga in för att få åtkomst.',
notfound_adaptive_title: 'Logga in för att visa den här sidan',
notfound_adaptive:
'Den här sidan kan kräva att du loggar in. Om du följde en länk, kontrollera att den är korrekt.',
notfound_adaptive_login: 'Logga in',
notfound_adaptive_registration_hint:
'Registrering kan vara tillgänglig beroende på organisationen.',
notfound_adaptive_no_access_title: 'Du kanske inte har åtkomst till den här sidan',
notfound_adaptive_no_access:
'Den här sidan kanske inte finns, eller så har ditt konto inte åtkomst till den. Om du följde en länk, kontrollera att den är korrekt.',
notfound_adaptive_login_again: 'Logga in igen',
notfound_goto_home: 'Gå till startsidan',
notfound_suggestions_title: 'Du kanske letar efter',
unexpected_error_title: 'Ett fel uppstod',
@@ -97,9 +102,9 @@ export const sv: TranslationLanguage = {
pdf_page_of: '${1} av ${2}',
pdf_mode_only_page: 'Endast denna sida',
pdf_mode_all: 'Alla sidor',
pdf_batch_range: 'Visar sidorna ${1}–${2} av ${3}.',
pdf_batch_previous: 'Föregående ${1} sidor',
pdf_batch_next: 'Nästa ${1} sidor',
pdf_limit_reached:
'Det gick inte att generera PDF för ${1} sidor, genereringen stoppades vid ${2}.',
pdf_limit_reached_continue: 'Utöka med ytterligare ${1} sidor.',
more: 'Mer',
link_tooltip_external_link: 'Extern länk till',
link_tooltip_email: 'Skicka e-post till',
+8 -5
View File
@@ -76,10 +76,14 @@ export const th: TranslationLanguage = {
notfound_title: 'ไม่พบหน้า',
notfound_link: 'ลิงก์นี้ชี้ไปยังหน้าที่ถูกลบหรือไม่มีอยู่อีกต่อไป',
notfound: 'หน้าที่คุณกำลังค้นหาไม่มีอยู่',
notfound_adaptive_title: 'หน้าไม่พร้อมใช้งาน',
notfound_adaptive: 'หน้านี้อาจมีอยู่ แต่คุณอาจต้องเข้าสู่ระบบเพื่อเข้าถึง',
notfound_adaptive_title: 'เข้าสู่ระบบเพื่อดูหน้านี้',
notfound_adaptive: 'หน้านี้อาจต้องเข้าสู่ระบบ หากคุณเปิดจากลิงก์ โปรดตรวจสอบว่าลิงก์ถูกต้อง',
notfound_adaptive_login: 'เข้าสู่ระบบ',
notfound_adaptive_registration_hint: 'การลงทะเบียนอาจใช้ได้ ขึ้นอยู่กับองค์กร',
notfound_adaptive_no_access_title: 'คุณอาจไม่มีสิทธิ์เข้าถึงหน้านี้',
notfound_adaptive_no_access:
'หน้านี้อาจไม่มีอยู่ หรือบัญชีของคุณอาจไม่มีสิทธิ์เข้าถึง หากคุณเปิดจากลิงก์ โปรดตรวจสอบว่าลิงก์ถูกต้อง',
notfound_adaptive_login_again: 'เข้าสู่ระบบอีกครั้ง',
notfound_goto_home: 'ไปที่หน้าแรก',
notfound_suggestions_title: 'คุณอาจกำลังมองหา',
unexpected_error_title: 'เกิดข้อผิดพลาด',
@@ -95,9 +99,8 @@ export const th: TranslationLanguage = {
pdf_page_of: '${1} จาก ${2}',
pdf_mode_only_page: 'เฉพาะหน้านี้',
pdf_mode_all: 'ทุกหน้า',
pdf_batch_range: 'แสดงหน้า ${1}–${2} จาก ${3}',
pdf_batch_previous: '${1} หน้าก่อนหน้า',
pdf_batch_next: '${1} หน้าถัดไป',
pdf_limit_reached: 'ไม่สามารถสร้าง PDF สำหรับ ${1} หน้าได้ การสร้างหยุดที่ ${2}',
pdf_limit_reached_continue: 'ขยายอีก ${1} หน้า',
more: 'เพิ่มเติม',
link_tooltip_external_link: 'ลิงก์ภายนอกไปยัง',
link_tooltip_email: 'ส่งอีเมลไปยัง',
+9 -5
View File
@@ -77,10 +77,15 @@ export const tr: TranslationLanguage = {
notfound_title: 'Sayfa bulunamadı',
notfound_link: 'Bu bağlantı kaldırılmış veya artık mevcut olmayan bir sayfaya işaret ediyor.',
notfound: 'Aradığınız sayfa mevcut değil.',
notfound_adaptive_title: 'Sayfa kullanılamıyor',
notfound_adaptive: 'Bu sayfa mevcut olabilir, ancak erişmek için oturum açmanız gerekebilir.',
notfound_adaptive_title: 'Bu sayfayı görüntülemek için oturum açın',
notfound_adaptive:
'Bu sayfa oturum açmanızı gerektirebilir. Bir bağlantıyı izlediyseniz doğru olduğunu kontrol edin.',
notfound_adaptive_login: 'Oturum aç',
notfound_adaptive_registration_hint: 'Kayıt, kuruluşa bağlı olarak mevcut olabilir.',
notfound_adaptive_no_access_title: 'Bu sayfaya erişiminiz olmayabilir',
notfound_adaptive_no_access:
'Bu sayfa mevcut olmayabilir veya hesabınızın bu sayfaya erişimi olmayabilir. Bir bağlantıyı izlediyseniz doğru olduğunu kontrol edin.',
notfound_adaptive_login_again: 'Tekrar oturum aç',
notfound_goto_home: 'Ana sayfaya git',
notfound_suggestions_title: 'Şunu arıyor olabilirsiniz',
unexpected_error_title: 'Bir hata oluştu',
@@ -96,9 +101,8 @@ export const tr: TranslationLanguage = {
pdf_page_of: '${1} / ${2}',
pdf_mode_only_page: 'Yalnızca bu sayfa',
pdf_mode_all: 'Tüm sayfalar',
pdf_batch_range: '${3} sayfadan ${1}–${2} arası gösteriliyor.',
pdf_batch_previous: 'Önceki ${1} sayfa',
pdf_batch_next: 'Sonraki ${1} sayfa',
pdf_limit_reached: '${1} sayfa için PDF oluşturulamadı, oluşturma ${2} konumunda durdu.',
pdf_limit_reached_continue: '${1} sayfa daha ekleyerek genişlet.',
more: 'Daha fazla',
link_tooltip_external_link: 'Harici bağlantı',
link_tooltip_email: 'E-posta gönder',
+9 -5
View File
@@ -77,10 +77,15 @@ export const uk: TranslationLanguage = {
notfound_title: 'Сторінку не знайдено',
notfound_link: 'Це посилання веде на сторінку, яку видалено або якої більше не існує.',
notfound: 'Сторінка, яку ви шукаєте, не існує.',
notfound_adaptive_title: 'Сторінка недоступна',
notfound_adaptive: 'Ця сторінка може існувати, але для доступу до неї може знадобитися вхід.',
notfound_adaptive_title: 'Увійдіть, щоб переглянути цю сторінку',
notfound_adaptive:
'Для перегляду цієї сторінки може знадобитися вхід. Якщо ви перейшли за посиланням, перевірте, чи воно правильне.',
notfound_adaptive_login: 'Увійти',
notfound_adaptive_registration_hint: 'Реєстрація може бути доступною залежно від організації.',
notfound_adaptive_no_access_title: 'Можливо, у вас немає доступу до цієї сторінки',
notfound_adaptive_no_access:
'Можливо, ця сторінка не існує або ваш обліковий запис не має до неї доступу. Якщо ви перейшли за посиланням, перевірте, чи воно правильне.',
notfound_adaptive_login_again: 'Увійти знову',
notfound_goto_home: 'Перейти на головну',
notfound_suggestions_title: 'Можливо, ви шукаєте',
unexpected_error_title: 'Сталася помилка',
@@ -96,9 +101,8 @@ export const uk: TranslationLanguage = {
pdf_page_of: '${1} з ${2}',
pdf_mode_only_page: 'Лише ця сторінка',
pdf_mode_all: 'Усі сторінки',
pdf_batch_range: 'Сторінки ${1}–${2} з ${3}.',
pdf_batch_previous: 'Попередні ${1} сторінок',
pdf_batch_next: 'Наступні ${1} сторінок',
pdf_limit_reached: 'Не вдалося створити PDF для ${1} сторінок, створення зупинилося на ${2}.',
pdf_limit_reached_continue: 'Розширити ще на ${1} сторінок.',
more: 'Більше',
link_tooltip_external_link: 'Зовнішнє посилання на',
link_tooltip_email: 'Надіслати електронний лист на',
+9 -5
View File
@@ -77,10 +77,15 @@ export const vi: TranslationLanguage = {
notfound_title: 'Không tìm thấy trang',
notfound_link: 'Liên kết này trỏ đến một trang đã bị xóa hoặc không còn tồn tại.',
notfound: 'Trang bạn đang tìm kiếm không tồn tại.',
notfound_adaptive_title: 'Trang không khả dụng',
notfound_adaptive: 'Trang này có thể tồn tại, nhưng bạn có thể cần đăng nhập để truy cập.',
notfound_adaptive_title: 'Đăng nhập để xem trang này',
notfound_adaptive:
'Trang này có thể yêu cầu bạn đăng nhập. Nếu bạn truy cập qua một liên kết, hãy kiểm tra xem liên kết đó có đúng không.',
notfound_adaptive_login: 'Đăng nhập',
notfound_adaptive_registration_hint: 'Việc đăng ký có thể khả dụng tùy theo tổ chức.',
notfound_adaptive_no_access_title: 'Có thể bạn không có quyền truy cập trang này',
notfound_adaptive_no_access:
'Trang này có thể không tồn tại hoặc tài khoản của bạn có thể không có quyền truy cập. Nếu bạn truy cập qua một liên kết, hãy kiểm tra xem liên kết đó có đúng không.',
notfound_adaptive_login_again: 'Đăng nhập lại',
notfound_goto_home: 'Đi tới trang chủ',
notfound_suggestions_title: 'Có thể bạn đang tìm',
unexpected_error_title: 'Đã xảy ra lỗi',
@@ -96,9 +101,8 @@ export const vi: TranslationLanguage = {
pdf_page_of: '${1} trên ${2}',
pdf_mode_only_page: 'Chỉ trang này',
pdf_mode_all: 'Tất cả trang',
pdf_batch_range: 'Đang hiển thị trang ${1}–${2} trên ${3}.',
pdf_batch_previous: '${1} trang trước',
pdf_batch_next: '${1} trang tiếp theo',
pdf_limit_reached: 'Không thể tạo PDF cho ${1} trang, quá trình tạo đã dừng tại ${2}.',
pdf_limit_reached_continue: 'Mở rộng thêm ${1} trang.',
more: 'Thêm',
link_tooltip_external_link: 'Liên kết ngoài tới',
link_tooltip_email: 'Gửi email tới',
@@ -75,10 +75,14 @@ export const yue: TranslationLanguage = {
notfound_title: '搵唔到頁面',
notfound_link: '呢條連結指向嘅頁面已被移除或已經唔存在。',
notfound: '你搵緊嘅頁面唔存在。',
notfound_adaptive_title: '頁面無法使用',
notfound_adaptive: '呢個頁面可能存在,但你可能需要登入先可以存取。',
notfound_adaptive_title: '登入先可以睇呢個頁面',
notfound_adaptive: '呢個頁面可能需要登入。如果你係經連結過嚟,請檢查連結係咪正確。',
notfound_adaptive_login: '登入',
notfound_adaptive_registration_hint: '視乎機構,可能可以註冊。',
notfound_adaptive_no_access_title: '你可能冇權限存取呢個頁面',
notfound_adaptive_no_access:
'呢個頁面可能唔存在,或者你嘅帳戶可能冇權限存取。如果你係經連結過嚟,請檢查連結係咪正確。',
notfound_adaptive_login_again: '重新登入',
notfound_goto_home: '前往首頁',
notfound_suggestions_title: '你可能喺度搵緊',
unexpected_error_title: '發生錯誤',
@@ -94,9 +98,8 @@ export const yue: TranslationLanguage = {
pdf_page_of: '${1} / ${2}',
pdf_mode_only_page: '只限呢頁',
pdf_mode_all: '所有頁面',
pdf_batch_range: '而家顯示緊第 ${1}–${2} 頁,總共 ${3} 頁。',
pdf_batch_previous: '上 ${1} 頁',
pdf_batch_next: '下 ${1} 頁',
pdf_limit_reached: '無法為 ${1} 頁產生 PDF,已喺 ${2} 停止。',
pdf_limit_reached_continue: '再加 ${1} 頁。',
more: '更多',
link_tooltip_external_link: '外部連結到',
link_tooltip_email: '傳送電郵到',
@@ -75,10 +75,14 @@ export const zh_tw: TranslationLanguage = {
notfound_title: '找不到頁面',
notfound_link: '此連結指向的頁面已被移除或不再存在。',
notfound: '您要尋找的頁面不存在。',
notfound_adaptive_title: '頁面無法使用',
notfound_adaptive: '此頁面可能存在,但您可能需要登入才能存取。',
notfound_adaptive_title: '登入以檢視此頁面',
notfound_adaptive: '此頁面可能需要登入。如果您是透過連結前往,請確認連結是否正確。',
notfound_adaptive_login: '登入',
notfound_adaptive_registration_hint: '視組織而定,可能可以註冊。',
notfound_adaptive_no_access_title: '您可能沒有此頁面的存取權限',
notfound_adaptive_no_access:
'此頁面可能不存在,或您的帳戶可能沒有存取權限。如果您是透過連結前往,請確認連結是否正確。',
notfound_adaptive_login_again: '重新登入',
notfound_goto_home: '前往首頁',
notfound_suggestions_title: '您可能在尋找',
unexpected_error_title: '發生錯誤',
@@ -94,9 +98,8 @@ export const zh_tw: TranslationLanguage = {
pdf_page_of: '${1} / ${2}',
pdf_mode_only_page: '僅此頁面',
pdf_mode_all: '所有頁面',
pdf_batch_range: '正在顯示第 ${1}–${2} 頁,共 ${3} 頁。',
pdf_batch_previous: '上 ${1} 頁',
pdf_batch_next: '下 ${1} 頁',
pdf_limit_reached: '無法為 ${1} 頁產生 PDF,已在 ${2} 停止產生。',
pdf_limit_reached_continue: '再擴展 ${1} 頁。',
more: '更多',
link_tooltip_external_link: '外部連結至',
link_tooltip_email: '傳送電子郵件至',
+8 -5
View File
@@ -76,10 +76,14 @@ export const zh: TranslationLanguage = {
notfound_title: '页面未找到',
notfound_link: '此链接指向已被删除或不再存在的页面。',
notfound: '您要找的页面不存在。',
notfound_adaptive_title: '页面无法访问',
notfound_adaptive: '该页面可能存在,但您可能需要登录后才能访问。',
notfound_adaptive_title: '登录以查看此页面',
notfound_adaptive: '此页面可能需要登录。如果您是通过链接访问的,请检查链接是否正确。',
notfound_adaptive_login: '登录',
notfound_adaptive_registration_hint: '视组织而定,可能可以注册。',
notfound_adaptive_no_access_title: '您可能没有此页面的访问权限',
notfound_adaptive_no_access:
'此页面可能不存在,或您的账户可能没有访问权限。如果您是通过链接访问的,请检查链接是否正确。',
notfound_adaptive_login_again: '重新登录',
notfound_goto_home: '前往首页',
notfound_suggestions_title: '您可能在寻找',
unexpected_error_title: '发生错误',
@@ -95,9 +99,8 @@ export const zh: TranslationLanguage = {
pdf_page_of: '${1} / ${2}',
pdf_mode_only_page: '仅本页',
pdf_mode_all: '所有页面',
pdf_batch_range: '正在显示第 ${1}–${2} 页,共 ${3} 页。',
pdf_batch_previous: '上 ${1} 页',
pdf_batch_next: '下 ${1} 页',
pdf_limit_reached: '无法为 ${1} 页生成 PDF,生成在 ${2} 页时停止。',
pdf_limit_reached_continue: '再扩展 ${1} 页。',
more: '更多',
link_tooltip_external_link: '外部链接到',
link_tooltip_email: '发送邮件到',
@@ -105,3 +105,30 @@ describe('preview auth redirects', () => {
}
);
});
describe('visitor payload', () => {
it('forwards the visitor country to the API', async () => {
const calls: { visitor?: unknown }[] = [];
const apiClientSpy = spyOn(api, 'apiClient').mockReturnValue({
urls: {
async resolvePublishedContentByUrl(body: { visitor?: unknown }) {
calls.push(body);
return { data: { target: 'external', redirect: 'https://example.com' } };
},
},
} as unknown as ReturnType<typeof api.apiClient>);
try {
await lookupPublishedContentByUrl({
url: 'https://docs.example.com',
apiToken: null,
redirectOnError: false,
visitorPayload: { type: 'human', country: 'FR' },
});
} finally {
apiClientSpy.mockRestore();
}
expect(calls[0]?.visitor).toEqual({ type: 'human', country: 'FR' });
});
});
+9
View File
@@ -14,6 +14,15 @@ export const GITBOOK_RUNTIME = (process.env.GITBOOK_RUNTIME ?? 'unknown') as
| 'cloudflare'
| 'unknown';
/**
* Deployment stage (`STAGE` from the Cloudflare wrangler configs, the target env on Vercel),
* defaulting to `dev` locally.
*/
export const GITBOOK_STAGE =
process.env.STAGE ??
process.env.VERCEL_TARGET_ENV ??
(process.env.NODE_ENV === 'development' ? 'dev' : undefined);
/**
* Main host on which GitBook is running.
*/
+43 -1
View File
@@ -1,6 +1,8 @@
import { describe, expect, it } from 'bun:test';
import { getPreviewRequestIdentifier, isPreviewRequest } from './preview';
import type { PublishedSiteContent } from '@gitbook/api';
import { getPreviewCookieResponse, getPreviewRequestIdentifier, isPreviewRequest } from './preview';
describe('isPreviewRequest', () => {
it('should return true for preview requests', () => {
@@ -23,3 +25,43 @@ describe('getPreviewRequestIdentifier', () => {
expect(getPreviewRequestIdentifier(previewRequestURL)).toBe('site_foo');
});
});
describe('getPreviewCookieResponse', () => {
// The site's canonical base path — deliberately different from the preview route prefix so the
// test fails if the cookie is scoped to it instead of the preview route.
const siteURLData = { siteBasePath: '/docs/' } as unknown as PublishedSiteContent;
it('scopes the cookie to the preview route prefix in url-host mode, not the site base path', () => {
const cookie = getPreviewCookieResponse({
name: 'gitbook-customization',
value: 'v',
mode: 'url-host',
siteRequestURL: new URL('https://sites.gitbook.com/preview/site_foo/hello/world'),
siteURLData,
});
expect(cookie.options?.path).toBe('/preview/site_foo');
expect(cookie.options?.sameSite).toBe('lax');
});
it('scopes the cookie to the proxied preview route prefix in url mode', () => {
const cookie = getPreviewCookieResponse({
name: 'gitbook-customization',
value: 'v',
mode: 'url',
siteRequestURL: new URL('https://sites.gitbook.com/preview/site_foo/hello/world'),
siteURLData,
});
expect(cookie.options?.path).toBe('/url/sites.gitbook.com/preview/site_foo');
});
it('falls back to the site base path for a non-preview url-host request', () => {
const cookie = getPreviewCookieResponse({
name: 'gitbook-customization',
value: 'v',
mode: 'url-host',
siteRequestURL: new URL('https://example.com/docs/hello/world'),
siteURLData,
});
expect(cookie.options?.path).toBe('/docs/');
});
});
+15 -2
View File
@@ -51,8 +51,21 @@ export function getPreviewCookieResponse(args: {
gitbookPreviewBaseURL.host + gitbookPreviewBaseURL.pathname.replace(/\/$/, '');
return `/url/${gitbookPreviewHostPath}/${getPreviewRequestIdentifier(siteRequestURL)}`;
}
case 'url-host':
return siteURLData.siteBasePath;
case 'url-host': {
// The whole site preview (all variants/sections/pages) is served under the preview
// route prefix `<previewBasePath>/<siteId>` (e.g. `/preview/<siteId>`). Scope the
// cookie to that prefix, derived from the request, so it is resent on every
// in-preview navigation. The resolved `siteBasePath` is the site's canonical base
// path and does not prefix the preview route, so relying on it makes the browser
// drop the cookie on the next page — the actual cause of the override being lost.
// Mirrors getVisitorAuthBasePath, which uses the request identifier for proxy
// requests. Fall back to `siteBasePath` for any preview not served under the route.
if (!isPreviewRequest(siteRequestURL)) {
return siteURLData.siteBasePath;
}
const gitbookPreviewBaseURL = new URL(GITBOOK_PREVIEW_BASE_URL);
return `${gitbookPreviewBaseURL.pathname.replace(/\/$/, '')}/${getPreviewRequestIdentifier(siteRequestURL)}`;
}
default:
assertNever(mode);
}
+92
View File
@@ -7,11 +7,14 @@ import {
getVisitorAuthCookieMaxAge,
getVisitorAuthCookieName,
getVisitorAuthCookieValue,
getVisitorCountry,
getVisitorToken,
getVisitorType,
getVisitorUnsignedClaims,
isRevalidationRequest,
normalizeVisitorURL,
parseHostnameList,
shouldSendVisitorCountry,
} from './visitors';
describe('getVisitorAuthToken', () => {
@@ -599,3 +602,92 @@ describe('isRevalidationRequest', () => {
expect(isRevalidationRequest(new Headers())).toBe(false);
});
});
describe('getVisitorCountry', () => {
const requestWith = (headers: Record<string, string>) => ({ headers: new Headers(headers) });
it('should prefer the OpenNext country header', () => {
expect(
getVisitorCountry(
requestWith({ 'x-open-next-country': 'FR', 'x-vercel-ip-country': 'US' })
)
).toBe('FR');
});
it('should fall back to the Vercel country header', () => {
expect(getVisitorCountry(requestWith({ 'x-vercel-ip-country': 'US' }))).toBe('US');
});
it('should normalize the country code to uppercase', () => {
expect(getVisitorCountry(requestWith({ 'x-open-next-country': ' fr ' }))).toBe('FR');
});
it.each(['XX', 'T1', 'FRA', 'F', ''])('should ignore the invalid country code %p', (value) => {
expect(getVisitorCountry(requestWith({ 'x-open-next-country': value }))).toBeUndefined();
});
it('should return undefined when no country header is present', () => {
expect(getVisitorCountry(requestWith({}))).toBeUndefined();
});
it('should prefer the forwarded country header on revalidation requests', () => {
expect(
getVisitorCountry(
requestWith({
'user-agent': 'gitbook-open-revalidation-worker',
'x-gitbook-country': 'DE',
'x-open-next-country': 'FR',
})
)
).toBe('DE');
});
it('should ignore the forwarded country header outside revalidation requests', () => {
expect(
getVisitorCountry(
requestWith({ 'x-gitbook-country': 'DE', 'x-open-next-country': 'FR' })
)
).toBe('FR');
expect(getVisitorCountry(requestWith({ 'x-gitbook-country': 'DE' }))).toBeUndefined();
});
it('should fall back to geolocation headers on revalidation requests without a forwarded country', () => {
expect(
getVisitorCountry(
requestWith({
'user-agent': 'gitbook-open-revalidation-worker',
'x-open-next-country': 'FR',
})
)
).toBe('FR');
});
});
describe('shouldSendVisitorCountry', () => {
it.each(['dev', 'preview', 'staging'])('should be enabled on the %p stage', (stage) => {
expect(shouldSendVisitorCountry('docs.example.com', stage)).toBe(true);
});
it.each(['production', undefined])(
'should be disabled for other hostnames on the %p stage',
(stage) => {
expect(shouldSendVisitorCountry('docs.example.com', stage)).toBe(false);
}
);
});
describe('parseHostnameList', () => {
it.each([undefined, '', ' , '])('should return an empty set for %p', (value) => {
expect(parseHostnameList(value).size).toBe(0);
});
it('should parse a single entry', () => {
expect(parseHostnameList('docs.foo.com')).toEqual(new Set(['docs.foo.com']));
});
it('should trim, lowercase and drop empty entries', () => {
expect(parseHostnameList(' Docs.Foo.com , ,bar.io')).toEqual(
new Set(['docs.foo.com', 'bar.io'])
);
});
});
+50
View File
@@ -106,6 +106,56 @@ export function getVisitorType(request: {
return detection.detected && detection.method !== 'heuristic' ? 'agent' : 'human';
}
// Production hostnames for which the visitor country is sent while the feature is rolled out.
// Set at build time from a GitHub Actions variable to keep customer hostnames out of the code.
const VISITOR_COUNTRY_HOSTNAMES = parseHostnameList(process.env.GITBOOK_VISITOR_COUNTRY_HOSTNAMES);
const VISITOR_COUNTRY_STAGES = new Set(['dev', 'preview', 'staging']);
/**
* Parse a comma-separated list of hostnames.
*/
export function parseHostnameList(value: string | undefined): Set<string> {
return new Set(
(value ?? '')
.split(',')
.map((hostname) => hostname.trim().toLowerCase())
.filter(Boolean)
);
}
/**
* Whether the visitor country should be sent when resolving the site URL.
*/
export function shouldSendVisitorCountry(hostname: string, stage: string | undefined): boolean {
return (
(!!stage && VISITOR_COUNTRY_STAGES.has(stage)) ||
VISITOR_COUNTRY_HOSTNAMES.has(hostname.toLowerCase())
);
}
/**
* Get the ISO 3166-1 alpha-2 country code of the visitor from the geolocation headers,
* or from `x-gitbook-country` when the request comes from the revalidation worker.
*/
export function getVisitorCountry(request: { headers: Headers }): string | undefined {
// The revalidation worker forwards the original visitor country; only trust it from there.
const country = (
(isRevalidationRequest(request.headers) && request.headers.get('x-gitbook-country')) ||
request.headers.get('x-open-next-country') ||
request.headers.get('x-vercel-ip-country') ||
''
)
.trim()
.toUpperCase();
// Cloudflare uses XX for unknown and T1 for Tor, which are not ISO codes.
if (!/^[A-Z]{2}$/.test(country) || country === 'XX' || country === 'T1') {
return undefined;
}
return country;
}
/**
* Get the visitor data for the request potentially including:
* - a JWT token that may contain signed claims or can be used for VA authentication.
+15 -2
View File
@@ -35,7 +35,12 @@ import {
normalizeRequestURL,
throwIfDataError,
} from '@/lib/data';
import { GITBOOK_DISABLE_INSIGHTS, isGitBookAssetsHostURL, isGitBookHostURL } from '@/lib/env';
import {
GITBOOK_DISABLE_INSIGHTS,
GITBOOK_STAGE,
isGitBookAssetsHostURL,
isGitBookHostURL,
} from '@/lib/env';
import { getImageResizingContextId } from '@/lib/images';
import { isAITrainingOrIndexingRequest } from '@/lib/indexing-crawlers';
import { MCP_SERVER_CARD_PATH, MCP_SERVER_CARD_WELL_KNOWN_PATH } from '@/lib/mcp/paths';
@@ -56,11 +61,13 @@ import {
type ResponseCookies,
getPathScopedCookieName,
getResponseCookiesForVisitorAuth,
getVisitorCountry,
getVisitorData,
getVisitorType,
isRevalidationRequest,
normalizeVisitorURL,
serveVisitorClaimsDataRequest,
shouldSendVisitorCountry,
} from '@/lib/visitors';
import { waitUntil } from '@/lib/waitUntil';
import { serveResizedImage } from '@/routes/image';
@@ -220,6 +227,10 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
//
request.headers.delete('x-gitbook-disable-tracking');
const visitorCountry = shouldSendVisitorCountry(siteRequestURL.hostname, GITBOOK_STAGE)
? getVisitorCountry(request)
: undefined;
const withAPIToken = async (apiToken: string | null) => {
const siteURLData = await throwIfDataError(
lookupPublishedContentByUrl({
@@ -228,6 +239,7 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
jwtToken: visitorToken?.token ?? undefined,
unsignedClaims,
type: getVisitorType(request),
...(visitorCountry ? { country: visitorCountry } : {}),
},
// When the visitor auth token is pulled from the cookie, set redirectOnError when calling resolvePublishedContentByUrl to allow
// redirecting when the token is invalid as we could be dealing with stale token stored in the cookie.
@@ -508,7 +520,8 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
siteId: siteURLData.site,
events,
request: {
url: siteRequestURL.toString(),
// A proxied site's request URL is the proxy's (`/sites/site_xxx/...`), not its public one.
url: siteCanonicalURL.toString(),
headers: requestHeaders,
},
})
@@ -0,0 +1,69 @@
import { describe, expect, it } from 'bun:test';
import { renderToReadableStream } from 'react-dom/server';
import { parseOpenAPI } from '@gitbook/openapi-parser';
import type { OpenAPIClientContext } from './context';
import { OpenAPIRootSchema } from './OpenAPISchemaServer';
import { resolveOpenAPISchemas } from './schemas/resolveOpenAPISchemas';
import { translations } from './translations';
const context: OpenAPIClientContext = {
translation: translations.en,
icons: {
chevronDown: null,
chevronRight: null,
plus: null,
copy: null,
check: null,
lock: null,
mcp: null,
hashtag: null,
},
expandAllModelSections: true,
scalarRuntimeURL: '',
$$isClientContext$$: true,
};
describe('OpenAPIRootSchema', () => {
it('should stop at a self-reference behind a nullable union when expanded', async () => {
const { filesystem } = await parseOpenAPI({
value: JSON.stringify({
openapi: '3.1.0',
info: { title: 'Test', version: '1.0.0' },
paths: {},
components: {
schemas: {
FilterClause: {
type: 'object',
properties: {
AND: {
anyOf: [
{
type: 'array',
items: { $ref: '#/components/schemas/FilterClause' },
},
{ type: 'null' },
],
},
},
},
},
},
}),
rootURL: 'memory://spec.json',
});
const resolved = await resolveOpenAPISchemas(filesystem, { schemas: ['FilterClause'] });
const schema = resolved?.schemas[0]?.schema;
if (!schema) {
throw new Error('FilterClause not resolved');
}
const stream = await renderToReadableStream(
<OpenAPIRootSchema schema={schema} context={context} />
);
const html = await new Response(stream).text();
expect(html).toContain('AND');
});
});
+8
View File
@@ -190,6 +190,14 @@ describe('extractNonNullTypes', () => {
});
describe('normalizeNullableUnion', () => {
it('should return the same object for the same input', () => {
const schema: OpenAPIV3_1.SchemaObject = {
anyOf: [{ type: 'array', items: { type: 'string' } }, { type: 'null' }],
};
expect(normalizeNullableUnion(schema)).toBe(normalizeNullableUnion(schema));
});
it('should collapse anyOf with a single non-null member into a nullable schema', () => {
const schema: OpenAPIV3_1.SchemaObject = {
anyOf: [{ type: 'string' }, { type: 'null' }],
+14
View File
@@ -287,6 +287,10 @@ function isNullSchema(schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject
return type === 'null';
}
// Circular-ref tracking compares schemas by identity: a fresh copy on every render lets a
// self-referencing nullable property (`anyOf: [{ items: Self }, null]`) recurse forever when expanded.
const normalizedNullableUnions = new WeakMap<OpenAPIV3.SchemaObject, OpenAPIV3.SchemaObject>();
/**
* Normalize the OpenAPI 3.1+ idiom of expressing nullability through `anyOf`/`oneOf`
* (e.g. `anyOf: [{ type: 'string' }, { type: 'null' }]`) into a regular nullable schema,
@@ -301,7 +305,17 @@ export function normalizeNullableUnion(
schema: OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject
): OpenAPIV3.SchemaObject {
const typed = schema as OpenAPIV3.SchemaObject;
const cached = normalizedNullableUnions.get(typed);
if (cached) {
return cached;
}
const normalized = normalizeNullableUnionUncached(typed);
normalizedNullableUnions.set(typed, normalized);
return normalized;
}
function normalizeNullableUnionUncached(typed: OpenAPIV3.SchemaObject): OpenAPIV3.SchemaObject {
const isAnyOf = Array.isArray(typed.anyOf);
const isOneOf = !isAnyOf && Array.isArray(typed.oneOf);
if (!isAnyOf && !isOneOf) {