Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2: search and ask AI #2889

Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into samy/rnd-6373-make-server-actions-work-by-pa…
…ssing-published-content-url
  • Loading branch information
SamyPesse committed Feb 28, 2025
commit 161dc4c9d3dffc3f68f14f2c19df639348bfb336
14 changes: 0 additions & 14 deletions packages/gitbook-v2/src/app/utils.ts
Original file line number Diff line number Diff line change
@@ -32,13 +32,6 @@ export function getStaticSiteContext(params: RouteLayoutParams) {
redirectOnError: false,
}
);

context.imageResizer = createImageResizer({
host,
linker: context.linker,
});

return context;
}

/**
@@ -64,13 +57,6 @@ export async function getDynamicSiteContext(params: RouteLayoutParams) {
redirectOnError: true,
}
);

context.imageResizer = createImageResizer({
host,
linker: context.linker,
});

return context;
}

/**
15 changes: 11 additions & 4 deletions packages/gitbook-v2/src/lib/context.ts
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ import { type GitBookDataFetcher, createDataFetcher } from '@v2/lib/data';
import { redirect } from 'next/navigation';
import { assert } from 'ts-essentials';
import { GITBOOK_API_TOKEN, GITBOOK_API_URL, GITBOOK_URL } from './env';
import { type ImageResizer, createNoopImageResizer } from './images';
import { type GitBookSpaceLinker, appendPrefixToLinker, createLinker } from './links';
import { type ImageResizer, createImageResizer } from './images';
import { type GitBookSpaceLinker, appendBasePathToLinker, createLinker } from './links';

/**
* Generic context when rendering content.
@@ -119,7 +119,6 @@ export function getBaseContext(input: {
apiToken: input.apiToken ?? GITBOOK_API_TOKEN,
apiEndpoint: input.apiEndpoint ?? GITBOOK_API_URL,
});
const imageResizer = createNoopImageResizer();
const gitbookURL = new URL(GITBOOK_URL);

const linker =
@@ -142,10 +141,18 @@ export function getBaseContext(input: {
};
}

const imageResizer = createImageResizer({
host: urlMode === 'url-host' ? url.host : gitbookURL.host,

// To ensure image resizing work for proxied sites,
// we serve images from the root of the site.
linker: appendBasePathToLinker(linker, url.pathname),
});

return {
dataFetcher,
imageResizer,
linker,
imageResizer,
};
}

3 changes: 2 additions & 1 deletion packages/gitbook/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -30,8 +30,9 @@ import {
normalizeVisitorAuthURL,
} from '@/lib/visitor-token';

import { joinPath, normalizePathname } from '@/lib/paths';
import { getProxyModeBasePath } from '@/lib/proxy';
import { MiddlewareHeaders } from '@v2/lib/middleware';
import { joinPath } from './lib/paths';

export const config = {
matcher:
Loading
Oops, something went wrong.
You are viewing a condensed version of this merge commit. You can view the full changes here.