mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-25 17:54:27 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dc5ec80893 | |||
| 429a63bb59 | |||
| b08a4f9acd | |||
| c9e2de32b6 | |||
| fa19dc41aa | |||
| 8fed05f354 | |||
| 9f0531484e | |||
| 30ea30421d | |||
| 4c01f40d7e |
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Keep links in generated Markdown usable outside the source page.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Handle optional emoji and icon values when rendering tags.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Point agents to the site MCP server from Markdown pages, the page HTML, llms.txt and llms-full.txt.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Serve the site AI Catalog as specification version 0.9, with identifiers in its `urn:air:{publisher}:{name}:{kind}` format.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fade the bottom of collapsed code blocks so readers can tell there is more code, matching the editor.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Answer Assistant questions with medium reasoning instead of low, matching AI search.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Bump Next.js to 16.4.6 and OpenNext (Cloudflare 1.20.17, AWS 4.1.16), keeping the dev-mode OOM patch.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Bump `@opennextjs/aws` to 4.2.0 and `@opennextjs/cloudflare` to 1.20.18.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix horizontal page scroll caused by card carousels bleeding past the viewport.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Retry direct site search on the site's own domain after a network error or timeout.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Name a site's MCP server as docs, such as "Acme Docs MCP Server", in AI clients and in the install commands and links, so it is not confused with a product's own MCP server.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gitbook/embed": minor
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Emit an `escape` event from the Docs Embed when Escape is pressed inside it and nothing in the embed used it, so the host can close its own panel.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gitbook/embed": minor
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Use the site's suggested questions when the embedded Assistant receives an empty or omitted list, including from older SDKs.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Reduce the wait after typing in site search to 100 ms.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix the table of contents keeping published pages busy in older Chrome versions such as Chrome 130.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix `'use cache'` entries never being stored in or read from R2 and the regional cache on Cloudflare.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Remove duplicated declarations from the global stylesheet.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@gitbook/icons": minor
|
||||
---
|
||||
|
||||
Add a `@gitbook/icons/validateIconName` entry that validates icon names without loading the icon labels and search terms.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Keep inline code and highlighted text readable when a paragraph crosses the bottom edge of a background page cover.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Keep published pages available when an integration block needs its connection or settings checked.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Keep published site search results visible while visitors refine a query.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
"@gitbook/icons": patch
|
||||
---
|
||||
|
||||
Add a skip link, keyboard navigation between content tabs, focusable table of contents toggles, and hide decorative icons from assistive technologies.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Apply the default language-aware search scope to legacy search links.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Reduce memory and CPU use of the OpenNext workers: minify the middleware, resolve the site context once per request, cache parsed OpenAPI descriptions across a spec, drop the redis client and the unused force-revalidate route from the server bundle.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Load the OpenAPI stylesheet only on pages with OpenAPI blocks.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Render the llms.txt directive as the first element in the page body so agents find it before the navigation.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Count only MCP tool calls in the MCP request insights event.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Answer GET requests to the MCP endpoint with an `Allow: POST` header.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Challenge MCP clients to authorize again when a visitor-auth site rejects their bearer token.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Support MCP protocol version 2025-11-25 on published site MCP servers.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Limit the MCP `searchDocumentation` tool to one language: the one the client passes in the new optional `language` argument, or else the language of the site variant the MCP endpoint is served from.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Flush insights events when the page is hidden, preload the search index at low priority and prioritize the dark page cover on dark-default sites.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Keep published revision URLs out of search results.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@gitbook/react-openapi": patch
|
||||
---
|
||||
|
||||
Copy the current spec's server in OpenAPI endpoint URLs instead of a server kept from a previously visited page.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Resolve GitBook links in OpenAPI schema descriptions to the site's published URLs instead of the editor.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Publish an OpenSearch description on every site so browsers can offer its search from the address bar.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Show H3 headings in the page outline.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Render a page's search keywords in its metadata.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": minor
|
||||
---
|
||||
|
||||
Open a link in the same or a new tab when its author chose one, instead of the site-wide external links setting.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'gitbook': patch
|
||||
---
|
||||
|
||||
Respect disabled change request previews on published sites.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix the search button accessible name, hoverable link previews, IME-safe Enter on Safari, cookie banner semantics, active outline item announcement and textarea shrinking.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Send change request and revision links to the site preview, where GitBook members can sign in, when a site turns off public change request previews.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
"@gitbook/embed": patch
|
||||
---
|
||||
|
||||
Respect reduced motion for enter and exit animations, keep the header separator and input focus visible in forced colors mode, and size mobile surfaces with dynamic viewport units.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Send only the site origin as referrer to third parties, and only let the embedding page open the embed messaging channel.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Remove the ChatGPT-specific plain text response for Markdown and llms.txt routes; these now always serve `text/markdown`.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Track the displayed position and search request ID when a visitor opens a search result.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Send site searches straight to the search API when the site hands out a search pass, and use the site's search route when it does not or when the API refuses a search.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Include navigation-hidden published spaces in direct browser search lookup and avoid latching on unknown spaces.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Send each search once on sites without a top header, and make search work between 768 and 1023 px wide.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Show loading rows shaped like search results while search waits for the server.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Show search results with one-line breadcrumbs and no icons or shortcut hints, and select the result under the mouse.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Stop caching site search results in the framework cache, so every search reaches the API.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Show one server-ordered search list and open its top result on Enter.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Load the data of the page actions menu from the menu itself, so it can be cached apart from the page body.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Follow the API's cache lifetime for site data, so a site preview shows layout changes soon after they are saved.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Show site revision previews as their site revision pins them, including OpenAPI specs.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Render small cards in a responsive four-column grid and carousel.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Ignore tag category references when displaying assigned tags and update filters.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Update the GitBook API SDK for site revision responses.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix wide content in Updates blocks overflowing into the page outline.
|
||||
@@ -49,7 +49,7 @@
|
||||
},
|
||||
"packages/embed": {
|
||||
"name": "@gitbook/embed",
|
||||
"version": "0.8.0",
|
||||
"version": "0.7.0",
|
||||
"dependencies": {
|
||||
"@gitbook/api": "catalog:",
|
||||
"bidc": "catalog:",
|
||||
@@ -109,7 +109,7 @@
|
||||
},
|
||||
"packages/gitbook": {
|
||||
"name": "gitbook",
|
||||
"version": "0.29.0",
|
||||
"version": "0.28.2",
|
||||
"dependencies": {
|
||||
"@base-ui/react": "catalog:",
|
||||
"@cloudflare/workers-types": "^4.20251011.0",
|
||||
@@ -228,7 +228,7 @@
|
||||
},
|
||||
"packages/icons": {
|
||||
"name": "@gitbook/icons",
|
||||
"version": "0.6.0",
|
||||
"version": "0.5.0",
|
||||
"bin": {
|
||||
"gitbook-icons": "./bin/gitbook-icons.js",
|
||||
},
|
||||
@@ -266,7 +266,7 @@
|
||||
},
|
||||
"packages/react-contentkit": {
|
||||
"name": "@gitbook/react-contentkit",
|
||||
"version": "0.7.19",
|
||||
"version": "0.7.18",
|
||||
"dependencies": {
|
||||
"@gitbook/api": "catalog:",
|
||||
"@gitbook/icons": "workspace:*",
|
||||
@@ -309,7 +309,7 @@
|
||||
},
|
||||
"packages/react-openapi": {
|
||||
"name": "@gitbook/react-openapi",
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.1",
|
||||
"dependencies": {
|
||||
"@base-ui/react": "catalog:",
|
||||
"@gitbook/expr": "workspace:*",
|
||||
@@ -1023,43 +1023,43 @@
|
||||
|
||||
"@oxfmt/binding-win32-x64-msvc": ["@oxfmt/binding-win32-x64-msvc@0.62.0", "", { "os": "win32", "cpu": "x64" }, "sha512-dlI5SY7XYQCiCBafntWagCR6HcAJB/NpsLtdlPx8x08+Osz8Ok1HHz1GZuusegCe/VoJ6pAnF5a4pd5OZAq7qQ=="],
|
||||
|
||||
"@oxlint/binding-android-arm-eabi": ["@oxlint/binding-android-arm-eabi@1.95.0", "", { "os": "android", "cpu": "arm" }, "sha512-hJna6w3COWJjfMPxomjZL82klTdrITm56PEpCsfO/xMkzQw/fNtJWauQ/YEwQqVttj0L5vDIa8rCcuhfAE3L4w=="],
|
||||
"@oxlint/binding-android-arm-eabi": ["@oxlint/binding-android-arm-eabi@1.93.0", "", { "os": "android", "cpu": "arm" }, "sha512-KKw70pbD5Pvq3G2lJ+WQ71XPMjCmg37rkSe2+mDqCRP3PoTSdDMuEi4UOnE8JBtyNM7bek61EC2s0Jt7S7u+Sg=="],
|
||||
|
||||
"@oxlint/binding-android-arm64": ["@oxlint/binding-android-arm64@1.95.0", "", { "os": "android", "cpu": "arm64" }, "sha512-uAIGZQ9uJVUeogeWOSboI3F7twOuM4mNuZcHXD9+LdYLcWp7J6kbtRUXJ6GVqcs5E0Cjb4emmSBK9FNrkGuhqQ=="],
|
||||
"@oxlint/binding-android-arm64": ["@oxlint/binding-android-arm64@1.93.0", "", { "os": "android", "cpu": "arm64" }, "sha512-fvr1fTUZGelwRxKDt64pf28aL1WaWgviwz3X+E/FcRYvrlEahH0NECRz/c1SY+K+KWmZk5uAf6h1kQnyBkp/2A=="],
|
||||
|
||||
"@oxlint/binding-darwin-arm64": ["@oxlint/binding-darwin-arm64@1.95.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Ogh1vfHO5vshKRop/He46r+WqC5BTqonYwhB4fp9e2gvOFvg1Xi6XsHTuM/lBSH85ZcaG+DS99EMAy9GcwDong=="],
|
||||
"@oxlint/binding-darwin-arm64": ["@oxlint/binding-darwin-arm64@1.93.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-VdvSN9JRf4Es6ZzoAdvEeh8tgKdw8L4H82WmA8MMPVfPdZGCwE/nI27Z1HrRHYQhPxOh4kmnxQEioSUFrOvDaw=="],
|
||||
|
||||
"@oxlint/binding-darwin-x64": ["@oxlint/binding-darwin-x64@1.95.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-kTrE1xfpQUBMMS50Ws6KY92N8OsJ8LE6JqxKqkHEY3KdsmguQ6kKVGSjzyt1HLwsSi0fQCvNRog8YRBBovD1AA=="],
|
||||
"@oxlint/binding-darwin-x64": ["@oxlint/binding-darwin-x64@1.93.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-QR1V890Ml0YGRG0F/iV0K9igG+pOhe+VWd+aZnxY849rRHZf3F2gEoQks5+GVHf105X9Mh/6HdShTP5juekG2g=="],
|
||||
|
||||
"@oxlint/binding-freebsd-x64": ["@oxlint/binding-freebsd-x64@1.95.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-ho7E1VCInK0VnpneRaI1BEpe1ceJE8VjxP2O9THWdReV6bth1Q4+80kYVGGK47mHRyZ2NGztQZ2dWRo6j1lavA=="],
|
||||
"@oxlint/binding-freebsd-x64": ["@oxlint/binding-freebsd-x64@1.93.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-jDfIbi30zZaKi+rTvig3sge+Xhi8pFFSgHxb0jzovc4qh8ETm/irKV9c7N/JsuwnYc5sbvf4IC8w1vQQ0IL+BA=="],
|
||||
|
||||
"@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/binding-linux-arm-gnueabihf@1.95.0", "", { "os": "linux", "cpu": "arm" }, "sha512-94afnouMHcnHr/OtRh07gG5LehC9M0GjiSoik3xxTtrmq6cWxXOTAhYlBtxa67u/GlycbnHlDoGJfYlTshcr/w=="],
|
||||
"@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/binding-linux-arm-gnueabihf@1.93.0", "", { "os": "linux", "cpu": "arm" }, "sha512-qtxZ714ND/koFgVH00QgxlzZiIbRPmguaPhnHRU5DFFtrtEdOrSnZD4U/H2AzXrXkZ59eQbMBnJwbum5XohrIQ=="],
|
||||
|
||||
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/binding-linux-arm-musleabihf@1.95.0", "", { "os": "linux", "cpu": "arm" }, "sha512-LEeclqV1/fafxPgJWN21Bri6HBBBZpEFluq/ZH7Avvu9HjJh/XOn6WwogJqX9X7pG2aITZ2nRH39+sUKEQt2WA=="],
|
||||
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/binding-linux-arm-musleabihf@1.93.0", "", { "os": "linux", "cpu": "arm" }, "sha512-5pJ9NjMvH7WMUqXB6bTTOSemBm39w2cod27Hu3+Yom/GhbTeNXlYcpDx1o4CgBP6fhp0YHG66TNdVaUm6sHjsA=="],
|
||||
|
||||
"@oxlint/binding-linux-arm64-gnu": ["@oxlint/binding-linux-arm64-gnu@1.95.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-EpXpEQKmgtkvc6RyU84LM1e3CrVDWQkgghVzf1hMGgwjBzgKAJ/QntHgnzmu5cNeLBfa7GPCY+gGXxEll8Adcg=="],
|
||||
"@oxlint/binding-linux-arm64-gnu": ["@oxlint/binding-linux-arm64-gnu@1.93.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-pRf+7jtbt2fHE23SX7qBxRgnBZicUgsoCK1PVIjnOk+t3a6UBkpt/GrKI99WlxsKUxftz/5nv/kfKvScmYywkw=="],
|
||||
|
||||
"@oxlint/binding-linux-arm64-musl": ["@oxlint/binding-linux-arm64-musl@1.95.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-+96Md8c2BAgFp8nWHrUrpqba87DoU+HVJYIun6qA+QKFoeNd3xAWq1JYE6da4nVli9GgwRpfncfRePcgmQQaIQ=="],
|
||||
"@oxlint/binding-linux-arm64-musl": ["@oxlint/binding-linux-arm64-musl@1.93.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-zM8Fd/K8sqGvsBcJBZ3oVZ3ctGWbszA08IaGt5gFFF5RcunppAI/ZnAXbouABvnWeJ//S44KKlfPZnDDbeiphg=="],
|
||||
|
||||
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/binding-linux-ppc64-gnu@1.95.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-6yG99vsXct3Uv536w6Z1s03w2makRKnE0q3eJSmf+W/IwPmO56QLk8XUA6ebu/R5peCbJ67HmcWqACH+kg/6Bg=="],
|
||||
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/binding-linux-ppc64-gnu@1.93.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-7qKCnvhZKDXJG2pdbLazd2hw4FxjJHbZOFrrbzyy5PdHfPLH9vnNUa1le01A8uItZuYKPBPncH+HCoEiFT4SgA=="],
|
||||
|
||||
"@oxlint/binding-linux-riscv64-gnu": ["@oxlint/binding-linux-riscv64-gnu@1.95.0", "", { "os": "linux", "cpu": "none" }, "sha512-Eir0Z4ldh55AsQUqVDlLF4Pw3lSFXIdAl8ZNgU8tp/gTwT9JVCzWY0o3+ys9pCcpTN0vCqBwwuQfAUxzbIgvcQ=="],
|
||||
"@oxlint/binding-linux-riscv64-gnu": ["@oxlint/binding-linux-riscv64-gnu@1.93.0", "", { "os": "linux", "cpu": "none" }, "sha512-2pgulxC6G8V5wE750NJE/fRkf9aO6i6yoj10wyaR2EdiNtan4OemsOtsQ0ZTXGdY8Q3IoTmlND3GYvjJsvikYg=="],
|
||||
|
||||
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/binding-linux-riscv64-musl@1.95.0", "", { "os": "linux", "cpu": "none" }, "sha512-ceRx+K2WJ7C3tIv+XjZS28oAoZ7DY29ZcWChPdXG5M100phI72FRDYwGRlWZEeDfmkROnarLTMKnnrQAtsC42Q=="],
|
||||
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/binding-linux-riscv64-musl@1.93.0", "", { "os": "linux", "cpu": "none" }, "sha512-yWsn6Gg2PnGG5jlyDz5+pHGiMTMiy4adaa4WRMzDgzB8efaShk1JMmTHIBSVLQMh0tYXRs4CN5uJCO79r4Mi4g=="],
|
||||
|
||||
"@oxlint/binding-linux-s390x-gnu": ["@oxlint/binding-linux-s390x-gnu@1.95.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-WbD3sM08ZDk2QE6060wK/omihQKbRm+LVzKIg4W5zNTbEhYJChciqX49UZuqW59RGF+wBUxzAup7egUIESTjUA=="],
|
||||
"@oxlint/binding-linux-s390x-gnu": ["@oxlint/binding-linux-s390x-gnu@1.93.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-WCn5plwp/ezS2RDPQKp0/EXEVRr9/dDexUdRKmsMFqzNM5xBSZ1wbsi3PuMk1VfkMRnI5BuazCsziCWMXRDOlw=="],
|
||||
|
||||
"@oxlint/binding-linux-x64-gnu": ["@oxlint/binding-linux-x64-gnu@1.95.0", "", { "os": "linux", "cpu": "x64" }, "sha512-F4ST2ZkFIiLL9OKyRCyC0KQQpwM5WIv0GTcMiZuYVa6xSRJHR05iVRqst+arOVudEPkhP47EnbuoC9UfVCYDyg=="],
|
||||
"@oxlint/binding-linux-x64-gnu": ["@oxlint/binding-linux-x64-gnu@1.93.0", "", { "os": "linux", "cpu": "x64" }, "sha512-F2CGjb9LAkzH+IYTZSzd1klQ1vk5z6Utjax64WeLByCkYXbVDbsun+Oy2hLfW2MDSKCvW+jwy/9ld0EPgdeu+A=="],
|
||||
|
||||
"@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.95.0", "", { "os": "linux", "cpu": "x64" }, "sha512-hEpYDZatpuxLrWlTlkwhHZ1e8QkL02aFS55BPQX1XA9iOd+yUEADGFF1iY6z+xkw6RkpzXFrtnDFe4/JNOLSRA=="],
|
||||
"@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.93.0", "", { "os": "linux", "cpu": "x64" }, "sha512-plf5DE2objcG8Tf7mXRuRa8tT8rzDkpjqXQtKoGsKHWkpgsialbON1+cCtoSEUTVbQUjXvuAm8vV9+3rR0yCBw=="],
|
||||
|
||||
"@oxlint/binding-openharmony-arm64": ["@oxlint/binding-openharmony-arm64@1.95.0", "", { "os": "none", "cpu": "arm64" }, "sha512-+JwIH9/uLgQXfxBvOAKzvp616m5i0fBR5ELEBHm5D+++fStBZ+74T7YW4xBpX13zNU2blr52Swoe3GTF1JyqRg=="],
|
||||
"@oxlint/binding-openharmony-arm64": ["@oxlint/binding-openharmony-arm64@1.93.0", "", { "os": "none", "cpu": "arm64" }, "sha512-Kp2yJrKvoTe9FfKdO/xwLNUbs2bYTMKx0+aoQD1s0h/Tx0kSgtHSdGmrk8tTKdluosjFbo88qYRIaNIX43AfFw=="],
|
||||
|
||||
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/binding-win32-arm64-msvc@1.95.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-pzJgcp3WkOSchukg5y5pn5mVIQ6P83RDI79YJ9gQZKed1pOgjhrmlc5AMizjuq6/P8VifhxzBsMqYI6LLjO2TA=="],
|
||||
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/binding-win32-arm64-msvc@1.93.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-vigjcHCFsR6KjnWTEVfaCxcMYapEuaK9FZa1MpewwQ1S+Xud3v0okfkj1RySsD6RF1NRHIjSlQSalTnKIaj3nA=="],
|
||||
|
||||
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/binding-win32-ia32-msvc@1.95.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-54MeQvLRXkJqF1nEFs7wb73SrnurZJQy9fVK4NdEwumNKVwyUUxpGHhvfDMIY2NqJZS7kz0pY9uVty5664Gt1Q=="],
|
||||
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/binding-win32-ia32-msvc@1.93.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-0Ot3BEe/AAr2/uQhe55r8CmPlperYk2mQmxdutOru7oU0kir6IiEVHb1TG3GORRlfra97lPHVDLhgmihiKzLrg=="],
|
||||
|
||||
"@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.95.0", "", { "os": "win32", "cpu": "x64" }, "sha512-I/Fn+Fed1qzb1k2uRjMe2VRtRN1+ZObyU+E76B6v/Ul3Z6JdeAW5zBHSe0n5d8a0ZyU4iorzVy0Rw9LYgo3MSQ=="],
|
||||
"@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.93.0", "", { "os": "win32", "cpu": "x64" }, "sha512-ZzzIIVs/Qkm8trUWYKF0OYub5ALlv50/3gsEZbKAvWgz+yNJX6uRmQ8ySPXU2Q0/Y9m4JCOjhpmC8XUYbPHX5Q=="],
|
||||
|
||||
"@panzoom/panzoom": ["@panzoom/panzoom@4.6.1", "", {}, "sha512-ogf/KhHHjj+DYAvHfaf3TXMQ8OE36pJtKpabLlx1OmpjcgtpCvkUoCiNONA8kuVRPGJdLiqMf0n8LRFXj1OyuA=="],
|
||||
|
||||
@@ -1365,17 +1365,17 @@
|
||||
|
||||
"@tsconfig/strictest": ["@tsconfig/strictest@2.0.6", "", {}, "sha512-tPOhmDhIUcDjvpDDYyiUdssP84Eqm7n5KxJe5J3/g+s6xoDIPAf+SIn06dhw7VkhxIvLOnhDDrX7tsqMHNEhDg=="],
|
||||
|
||||
"@turbo/darwin-64": ["@turbo/darwin-64@2.11.13", "", { "os": "darwin", "cpu": "x64" }, "sha512-5IT29i4j55E5O66+la7L8Y46ut7dFaNZqrgUIYYNtcpMt9Ql7aYnSQb/6tZ+prE2AfX1RBCAtRJE41txS2rG3w=="],
|
||||
"@turbo/darwin-64": ["@turbo/darwin-64@2.11.11", "", { "os": "darwin", "cpu": "x64" }, "sha512-HMMeUIEAsmyIbSYn1ySvF/4gGMa0joiTMq4dQDuloIAnOpbtFT3JEiVsYnASdTWDXvplbRbZlqjU1EBeSR9G1A=="],
|
||||
|
||||
"@turbo/darwin-arm64": ["@turbo/darwin-arm64@2.11.13", "", { "os": "darwin", "cpu": "arm64" }, "sha512-YFJPayVNlhSPRIZSeERiZYGKKqPs6N6qGhim8J3GtBdv5ZjUNF1ixfnAAyCVTqFEnMSkn1W7F0Y07kca8EjWsg=="],
|
||||
"@turbo/darwin-arm64": ["@turbo/darwin-arm64@2.11.11", "", { "os": "darwin", "cpu": "arm64" }, "sha512-+8iySNgqYWY6PZYUQzYu6zn0C04z2OEq1vQ6oMGsJ9sxN6wOpg1gzi1AJ5VKDHviWvMUjhqng51hTEQZOuiqYQ=="],
|
||||
|
||||
"@turbo/linux-64": ["@turbo/linux-64@2.11.13", "", { "os": [ "linux", "android", ], "cpu": "x64" }, "sha512-R5RIQflV4ffBDNuUwjmtmzIr6Y2UeyeeHTtultYF7cnFn3tG1RZ4GRBlpjUhHB6JxuR7l1B450hlbzdtlD3ghg=="],
|
||||
"@turbo/linux-64": ["@turbo/linux-64@2.11.11", "", { "os": [ "linux", "android", ], "cpu": "x64" }, "sha512-uImTKFYCFKsoFxjaXeJXlMPv4uU3OIIDjyzoIwYVqOtu9LnCZ/5/fzu/WP6+G9YfwGAPRplTHkKFfcI5t97RGw=="],
|
||||
|
||||
"@turbo/linux-arm64": ["@turbo/linux-arm64@2.11.13", "", { "os": [ "linux", "android", ], "cpu": "arm64" }, "sha512-AwV8pVO/cH/lwx1B7SGfzUA/3e6vmPaygFp9NOSRESs6t3Wr63zrBuXlluDogAOIxIMlHDB2ZbBueDsBnQxh2Q=="],
|
||||
"@turbo/linux-arm64": ["@turbo/linux-arm64@2.11.11", "", { "os": [ "linux", "android", ], "cpu": "arm64" }, "sha512-Y7xffSVfyyYRGzNy6PLdrFL4xXN6iTuR3W0SyJvH/yd3d4defA6dansZwJpPDVnIpD8a2Qn256DwY/Qin4Ip4g=="],
|
||||
|
||||
"@turbo/windows-64": ["@turbo/windows-64@2.11.13", "", { "os": "win32", "cpu": "x64" }, "sha512-PGXYTaFaN3FZloe4RffNGJmfB+TIWlqQgKK1PVyKwPN+PUzxGa+byxHBWFHredMaVbnUc6L/F6/QR4iHyM/wug=="],
|
||||
"@turbo/windows-64": ["@turbo/windows-64@2.11.11", "", { "os": "win32", "cpu": "x64" }, "sha512-e2WqNtkPGo3QDwNNwwBo89Dx3PtSJ9Wp9QuRNzn80rrRnSHB+1mfBMZTpdHjA8/G/sG9rl76TdWdpgVsimjRdg=="],
|
||||
|
||||
"@turbo/windows-arm64": ["@turbo/windows-arm64@2.11.13", "", { "os": "win32", "cpu": "arm64" }, "sha512-YdRHWstBUHWt/eChOEM4f9LT0dPiWK5SNgtV77bLCr3JNke9M5E7metqelNYj+tXe36dH0BZrk2CMnFlWqHKng=="],
|
||||
"@turbo/windows-arm64": ["@turbo/windows-arm64@2.11.11", "", { "os": "win32", "cpu": "arm64" }, "sha512-LURivfmgv34Osm8NR1gZGx4vdlux9KAgRM+FoooXNG0838ff0+akWZ76iPSke0NS2rsf7Z4Gw+YSaygzNTZuRA=="],
|
||||
|
||||
"@tusbar/cache-control": ["@tusbar/cache-control@1.0.2", "", {}, "sha512-PXfjYTYBVvMPYCLDWj+xIOA9ITFbbhWCHzLcqUCJ5TPGm4JO4cxpGb7x3K8Q1K1ADgNgfBxLsDcTMVRydtZB9A=="],
|
||||
|
||||
@@ -2689,7 +2689,7 @@
|
||||
|
||||
"oxfmt": ["oxfmt@0.62.0", "", { "dependencies": { "tinypool": "2.1.0" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.62.0", "@oxfmt/binding-android-arm64": "0.62.0", "@oxfmt/binding-darwin-arm64": "0.62.0", "@oxfmt/binding-darwin-x64": "0.62.0", "@oxfmt/binding-freebsd-x64": "0.62.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.62.0", "@oxfmt/binding-linux-arm-musleabihf": "0.62.0", "@oxfmt/binding-linux-arm64-gnu": "0.62.0", "@oxfmt/binding-linux-arm64-musl": "0.62.0", "@oxfmt/binding-linux-ppc64-gnu": "0.62.0", "@oxfmt/binding-linux-riscv64-gnu": "0.62.0", "@oxfmt/binding-linux-riscv64-musl": "0.62.0", "@oxfmt/binding-linux-s390x-gnu": "0.62.0", "@oxfmt/binding-linux-x64-gnu": "0.62.0", "@oxfmt/binding-linux-x64-musl": "0.62.0", "@oxfmt/binding-openharmony-arm64": "0.62.0", "@oxfmt/binding-win32-arm64-msvc": "0.62.0", "@oxfmt/binding-win32-ia32-msvc": "0.62.0", "@oxfmt/binding-win32-x64-msvc": "0.62.0" }, "peerDependencies": { "svelte": "^5.0.0", "vite-plus": "*" }, "optionalPeers": ["svelte", "vite-plus"], "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-vxgGHTmnDU9j4CX7dDBLzxgmHxfda/yPcgJkGCMUSCwRmz+euo/V08xXLNgXTeqAB9Fhf3Pe2nO1RNKLCVgphQ=="],
|
||||
|
||||
"oxlint": ["oxlint@1.95.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.95.0", "@oxlint/binding-android-arm64": "1.95.0", "@oxlint/binding-darwin-arm64": "1.95.0", "@oxlint/binding-darwin-x64": "1.95.0", "@oxlint/binding-freebsd-x64": "1.95.0", "@oxlint/binding-linux-arm-gnueabihf": "1.95.0", "@oxlint/binding-linux-arm-musleabihf": "1.95.0", "@oxlint/binding-linux-arm64-gnu": "1.95.0", "@oxlint/binding-linux-arm64-musl": "1.95.0", "@oxlint/binding-linux-ppc64-gnu": "1.95.0", "@oxlint/binding-linux-riscv64-gnu": "1.95.0", "@oxlint/binding-linux-riscv64-musl": "1.95.0", "@oxlint/binding-linux-s390x-gnu": "1.95.0", "@oxlint/binding-linux-x64-gnu": "1.95.0", "@oxlint/binding-linux-x64-musl": "1.95.0", "@oxlint/binding-openharmony-arm64": "1.95.0", "@oxlint/binding-win32-arm64-msvc": "1.95.0", "@oxlint/binding-win32-ia32-msvc": "1.95.0", "@oxlint/binding-win32-x64-msvc": "1.95.0" }, "peerDependencies": { "oxlint-tsgolint": ">=7.0.2008", "vite-plus": "*" }, "optionalPeers": ["oxlint-tsgolint", "vite-plus"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-eNzjFjm1TU02/+ohAJjOB7aekRQgTXhOWxMGscEm8VJMokNnnix+PCZn7kqIuGIqxAoBnHxatqlN3Chz3N6PKA=="],
|
||||
"oxlint": ["oxlint@1.93.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.93.0", "@oxlint/binding-android-arm64": "1.93.0", "@oxlint/binding-darwin-arm64": "1.93.0", "@oxlint/binding-darwin-x64": "1.93.0", "@oxlint/binding-freebsd-x64": "1.93.0", "@oxlint/binding-linux-arm-gnueabihf": "1.93.0", "@oxlint/binding-linux-arm-musleabihf": "1.93.0", "@oxlint/binding-linux-arm64-gnu": "1.93.0", "@oxlint/binding-linux-arm64-musl": "1.93.0", "@oxlint/binding-linux-ppc64-gnu": "1.93.0", "@oxlint/binding-linux-riscv64-gnu": "1.93.0", "@oxlint/binding-linux-riscv64-musl": "1.93.0", "@oxlint/binding-linux-s390x-gnu": "1.93.0", "@oxlint/binding-linux-x64-gnu": "1.93.0", "@oxlint/binding-linux-x64-musl": "1.93.0", "@oxlint/binding-openharmony-arm64": "1.93.0", "@oxlint/binding-win32-arm64-msvc": "1.93.0", "@oxlint/binding-win32-ia32-msvc": "1.93.0", "@oxlint/binding-win32-x64-msvc": "1.93.0" }, "peerDependencies": { "oxlint-tsgolint": ">=7.0.2005", "vite-plus": "*" }, "optionalPeers": ["oxlint-tsgolint", "vite-plus"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-19JMsQFX+YvEbcUTFQxjTwhvs0Ibg0D6CFneSLgpwnACWcY/6LjhpGpkPodh0T5aIT1pjMTLlYaeBFzaVgugTA=="],
|
||||
|
||||
"p-filter": ["p-filter@2.1.0", "", { "dependencies": { "p-map": "^2.0.0" } }, "sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw=="],
|
||||
|
||||
@@ -3121,7 +3121,7 @@
|
||||
|
||||
"tsx": ["tsx@4.21.0", "", { "dependencies": { "esbuild": "~0.27.0", "get-tsconfig": "^4.7.5" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "bin": { "tsx": "dist/cli.mjs" } }, "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw=="],
|
||||
|
||||
"turbo": ["turbo@2.11.13", "", { "optionalDependencies": { "@turbo/darwin-64": "2.11.13", "@turbo/darwin-arm64": "2.11.13", "@turbo/linux-64": "2.11.13", "@turbo/linux-arm64": "2.11.13", "@turbo/windows-64": "2.11.13", "@turbo/windows-arm64": "2.11.13" }, "bin": { "turbo": "bin/turbo" } }, "sha512-2EZ8StW6tqaj71HGF60oUOmJrPQHidmZ5dcwv2VORofya9JthVrfZhxbzRMx/QxjPwYi754i2h5RFsZSDzpnaQ=="],
|
||||
"turbo": ["turbo@2.11.11", "", { "optionalDependencies": { "@turbo/darwin-64": "2.11.11", "@turbo/darwin-arm64": "2.11.11", "@turbo/linux-64": "2.11.11", "@turbo/linux-arm64": "2.11.11", "@turbo/windows-64": "2.11.11", "@turbo/windows-arm64": "2.11.11" }, "bin": { "turbo": "bin/turbo" } }, "sha512-AI4UJbUE/2cVZdoXJ4PODc8qvrjhQQX9Fa93eKGOI6Ims/w7+kUIb9T1jhlgSnZcf+gtUruci/ohSwqtNNC5Yw=="],
|
||||
|
||||
"type": ["type@2.7.3", "", {}, "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ=="],
|
||||
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.31.1",
|
||||
"oxfmt": "^0.62.0",
|
||||
"oxlint": "^1.95.0",
|
||||
"turbo": "^2.11.13",
|
||||
"oxlint": "^1.93.0",
|
||||
"turbo": "^2.11.11",
|
||||
"vercel": "50.37.3"
|
||||
},
|
||||
"packageManager": "bun@1.3.7",
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
# @gitbook/embed
|
||||
|
||||
## 0.8.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- a9535cd: Emit an `escape` event from the Docs Embed when Escape is pressed inside it and nothing in the embed used it, so the host can close its own panel.
|
||||
- 6b2e806: Use the site's suggested questions when the embedded Assistant receives an empty or omitted list, including from older SDKs.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 65210b7: Respect reduced motion for enter and exit animations, keep the header separator and input focus visible in forced colors mode, and size mobile surfaces with dynamic viewport units.
|
||||
|
||||
## 0.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"version": "0.8.0",
|
||||
"version": "0.7.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@gitbook/api": "catalog:",
|
||||
|
||||
@@ -1,82 +1,5 @@
|
||||
# gitbook
|
||||
|
||||
## 0.29.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 7ad3fff: Open a link in the same or a new tab when its author chose one, instead of the site-wide external links setting.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4eb32b1: Keep links in generated Markdown usable outside the source page.
|
||||
- 13c0ff0: Handle optional emoji and icon values when rendering tags.
|
||||
- 5755e6d: Point agents to the site MCP server from Markdown pages, the page HTML, llms.txt and llms-full.txt.
|
||||
- bd38317: Serve the site AI Catalog as specification version 0.9, with identifiers in its `urn:air:{publisher}:{name}:{kind}` format.
|
||||
- 960d7ec: Fade the bottom of collapsed code blocks so readers can tell there is more code, matching the editor.
|
||||
- 818cbbe: Answer Assistant questions with medium reasoning instead of low, matching AI search.
|
||||
- ddccd3d: Bump Next.js to 16.4.6 and OpenNext (Cloudflare 1.20.17, AWS 4.1.16), keeping the dev-mode OOM patch.
|
||||
- b0f3822: Bump `@opennextjs/aws` to 4.2.0 and `@opennextjs/cloudflare` to 1.20.18.
|
||||
- 0c3a51e: Fix horizontal page scroll caused by card carousels bleeding past the viewport.
|
||||
- 22df281: Name a site's MCP server as docs, such as "Acme Docs MCP Server", in AI clients and in the install commands and links, so it is not confused with a product's own MCP server.
|
||||
- a9535cd: Emit an `escape` event from the Docs Embed when Escape is pressed inside it and nothing in the embed used it, so the host can close its own panel.
|
||||
- 6b2e806: Use the site's suggested questions when the embedded Assistant receives an empty or omitted list, including from older SDKs.
|
||||
- 7e2658a: Reduce the wait after typing in site search to 100 ms.
|
||||
- 7af524a: Prevent self-redirect loops and skip redirects targeting hidden adaptive content.
|
||||
- ae1e370: Fix the table of contents keeping published pages busy in older Chrome versions such as Chrome 130.
|
||||
- c85d84f: Fix `'use cache'` entries never being stored in or read from R2 and the regional cache on Cloudflare.
|
||||
- 5997a66: Remove duplicated declarations from the global stylesheet.
|
||||
- c3df458: Keep inline code and highlighted text readable when a paragraph crosses the bottom edge of a background page cover.
|
||||
- 1ecd2ca: Keep published pages available when an integration block needs its connection or settings checked.
|
||||
- 7cee30e: Keep published site search results visible while visitors refine a query.
|
||||
- 265ca4b: Add a skip link, keyboard navigation between content tabs, focusable table of contents toggles, and hide decorative icons from assistive technologies.
|
||||
- 76e1abd: Apply the default language-aware search scope to legacy search links.
|
||||
- 9fcde5f: Reduce memory and CPU use of the OpenNext workers: minify the middleware, resolve the site context once per request, cache parsed OpenAPI descriptions across a spec, drop the redis client and the unused force-revalidate route from the server bundle.
|
||||
- 9b5b8c8: Load the OpenAPI stylesheet only on pages with OpenAPI blocks.
|
||||
- a3b5ce5: Render the llms.txt directive as the first element in the page body so agents find it before the navigation.
|
||||
- 21b96e1: Count only MCP tool calls in the MCP request insights event.
|
||||
- adbc358: Answer GET requests to the MCP endpoint with an `Allow: POST` header.
|
||||
- fa7d4a9: Challenge MCP clients to authorize again when a visitor-auth site rejects their bearer token.
|
||||
- 596b8c5: Support MCP protocol version 2025-11-25 on published site MCP servers.
|
||||
- adfd921: Limit the MCP `searchDocumentation` tool to one language: the one the client passes in the new optional `language` argument, or else the language of the site variant the MCP endpoint is served from.
|
||||
- 19660ed: Flush insights events when the page is hidden, preload the search index at low priority and prioritize the dark page cover on dark-default sites.
|
||||
- a035d19: Keep published revision URLs out of search results.
|
||||
- 867da7b: Resolve GitBook links in OpenAPI schema descriptions to the site's published URLs instead of the editor.
|
||||
- 506aa78: Publish an OpenSearch description on every site so browsers can offer its search from the address bar.
|
||||
- c09da2e: Show H3 headings in the page outline.
|
||||
- d2be885: Render a page's search keywords in its metadata.
|
||||
- 6cdbafc: Respect disabled change request previews on published sites.
|
||||
- 19660ed: Fix the search button accessible name, hoverable link previews, IME-safe Enter on Safari, cookie banner semantics, active outline item announcement and textarea shrinking.
|
||||
- d2c56e5: Send change request and revision links to the site preview, where GitBook members can sign in, when a site turns off public change request previews.
|
||||
- 65210b7: Respect reduced motion for enter and exit animations, keep the header separator and input focus visible in forced colors mode, and size mobile surfaces with dynamic viewport units.
|
||||
- 3e86382: Send only the site origin as referrer to third parties, and only let the embedding page open the embed messaging channel.
|
||||
- 7d1cd9f: Remove the ChatGPT-specific plain text response for Markdown and llms.txt routes; these now always serve `text/markdown`.
|
||||
- 3ec61a7: Drop description HTML supplied by OpenAPI specs and sanitize example descriptions that could render HTML.
|
||||
- 63a4a98: Track the displayed position and search request ID when a visitor opens a search result.
|
||||
- cf8c3d5: Send site searches straight to the search API when the site hands out a search pass, and use the site's search route when it does not or when the API refuses a search.
|
||||
- 48fe81b: Include navigation-hidden published spaces in direct browser search lookup and avoid latching on unknown spaces.
|
||||
- adbec4c: Send each search once on sites without a top header, and make search work between 768 and 1023 px wide.
|
||||
- 8f5175e: Show loading rows shaped like search results while search waits for the server.
|
||||
- 386a5c1: Show search results with one-line breadcrumbs and no icons or shortcut hints, and select the result under the mouse.
|
||||
- b145bfc: Stop caching site search results in the framework cache, so every search reaches the API.
|
||||
- 7856e08: Show one server-ordered search list and open its top result on Enter.
|
||||
- a10eff9: Load the data of the page actions menu from the menu itself, so it can be cached apart from the page body.
|
||||
- 1c71849: Follow the API's cache lifetime for site data, so a site preview shows layout changes soon after they are saved.
|
||||
- 7f08fb1: Show site revision previews as their site revision pins them, including OpenAPI specs.
|
||||
- b5f7e55: Render small cards in a responsive four-column grid and carousel.
|
||||
- 8dd308b: Ignore tag category references when displaying assigned tags and update filters.
|
||||
- 4cbbda7: Update the GitBook API SDK for site revision responses.
|
||||
- 060f1f6: Fix wide content in Updates blocks overflowing into the page outline.
|
||||
- Updated dependencies [a9535cd]
|
||||
- Updated dependencies [6b2e806]
|
||||
- Updated dependencies [9fcde5f]
|
||||
- Updated dependencies [265ca4b]
|
||||
- Updated dependencies [262749a]
|
||||
- Updated dependencies [65210b7]
|
||||
- @gitbook/embed@0.8.0
|
||||
- @gitbook/icons@0.6.0
|
||||
- @gitbook/react-openapi@2.0.2
|
||||
- @gitbook/react-contentkit@0.7.19
|
||||
|
||||
## 0.28.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -781,7 +781,7 @@ const searchPassTestCases: Test[] = [
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Dropped API request: the search falls back to the route after its time limit',
|
||||
name: 'Dropped API request: search uses the site proxy before falling back to the route',
|
||||
url: '',
|
||||
screenshot: false,
|
||||
run: async (page) => {
|
||||
@@ -791,6 +791,18 @@ const searchPassTestCases: Test[] = [
|
||||
await page.route(SEARCH_API_URL, (route) => {
|
||||
apiCalls.push(route.request());
|
||||
});
|
||||
const proxyCalls: Request[] = [];
|
||||
await page.route(
|
||||
/\/~gitbook\/search-direct\/orgs\/[^/]+\/sites\/[^/]+$/,
|
||||
async (route) => {
|
||||
proxyCalls.push(route.request());
|
||||
if (proxyCalls.length === 1) {
|
||||
await route.fulfill({ json: { items: [SEARCH_PASS_RECORD] } });
|
||||
return;
|
||||
}
|
||||
await route.fulfill({ status: 502 });
|
||||
}
|
||||
);
|
||||
const routeSearches = trackRouteSearches(page);
|
||||
await waitForCookiesDialog(page);
|
||||
|
||||
@@ -798,12 +810,24 @@ const searchPassTestCases: Test[] = [
|
||||
await typeSearch(page, 'gitbook');
|
||||
await expect.poll(() => apiCalls.length, { timeout: 30_000 }).toBe(1);
|
||||
await page.clock.fastForward(5_000);
|
||||
await expect.poll(() => routeSearches.length, { timeout: 30_000 }).toBe(1);
|
||||
expect(routeSearches[0]?.headers()['x-gitbook-search-fallback']).toBe('timeout');
|
||||
expect((await routeSearches[0]?.response())?.status()).toBe(200);
|
||||
await expect(
|
||||
page
|
||||
.getByTestId('search-record-result')
|
||||
.filter({ hasText: SEARCH_PASS_RECORD.title })
|
||||
).toBeVisible({ timeout: 30_000 });
|
||||
expect(routeSearches).toHaveLength(0);
|
||||
expect((await proxyCalls[0]?.allHeaders())?.['x-gitbook-search-pass']).toBe(
|
||||
'test-search-pass-1'
|
||||
);
|
||||
|
||||
await typeSearch(page, ' editor');
|
||||
await expect.poll(() => routeSearches.length, { timeout: 30_000 }).toBe(1);
|
||||
expect(routeSearches[0]?.headers()['x-gitbook-search-fallback']).toBe('502');
|
||||
expect((await routeSearches[0]?.response())?.status()).toBe(200);
|
||||
|
||||
await typeSearch(page, ' blocks');
|
||||
await expect.poll(() => routeSearches.length, { timeout: 30_000 }).toBe(2);
|
||||
expect(proxyCalls).toHaveLength(2);
|
||||
expect(apiCalls).toHaveLength(1);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "0.29.0",
|
||||
"version": "0.28.2",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@base-ui/react": "catalog:",
|
||||
|
||||
@@ -4,10 +4,12 @@ import { createSearchPassStore } from './search-pass-store';
|
||||
import type { DirectSearchProps } from '@/lib/search-results';
|
||||
|
||||
const endpoint = 'https://api.gitbook.com/v1/orgs/org_1/sites/site_1/search';
|
||||
const proxyURL = '/~gitbook/search-direct/orgs/org_1/sites/site_1';
|
||||
const directSearch: DirectSearchProps = {
|
||||
apiURL: 'https://api.gitbook.com',
|
||||
organizationId: 'org_1',
|
||||
siteId: 'site_1',
|
||||
proxyURL,
|
||||
linker: {
|
||||
urlMode: 'url-host',
|
||||
siteHost: 'docs.example.com',
|
||||
@@ -60,6 +62,49 @@ describe('createSearchPassStore', () => {
|
||||
let restore: (() => void) | undefined;
|
||||
afterEach(() => restore?.());
|
||||
|
||||
it('switches to the site proxy after an API network failure', async () => {
|
||||
const fetchSpy = spyOn(globalThis, 'fetch')
|
||||
.mockResolvedValueOnce(Response.json({ token: 'pass-1', expiresIn: 300_000 }))
|
||||
.mockRejectedValueOnce(new TypeError('Failed to fetch'))
|
||||
.mockImplementation(async () => Response.json({ items: [] }));
|
||||
restore = () => fetchSpy.mockRestore();
|
||||
const store = createSearchPassStore(directSearch);
|
||||
await store.requestPass();
|
||||
|
||||
expect(await search(store)).toEqual({ type: 'results', results: [] });
|
||||
expect(await search(store)).toEqual({ type: 'results', results: [] });
|
||||
expect(fetchSpy.mock.calls.map(([url]) => url)).toEqual([
|
||||
directSearch.passURL,
|
||||
endpoint,
|
||||
proxyURL,
|
||||
proxyURL,
|
||||
]);
|
||||
const init = fetchSpy.mock.calls[2]?.[1];
|
||||
expect(init).toMatchObject({ mode: 'same-origin', credentials: 'omit' });
|
||||
expect(init?.body).toBe(JSON.stringify({ query: 'tokens', mode: 'all' }));
|
||||
const headers = new Headers(init?.headers);
|
||||
expect(headers.get('x-gitbook-search-pass')).toBe('pass-1');
|
||||
expect(headers.has('authorization')).toBe(false);
|
||||
});
|
||||
|
||||
it('uses the server route after the site proxy also fails', async () => {
|
||||
const fetchSpy = spyOn(globalThis, 'fetch')
|
||||
.mockResolvedValueOnce(Response.json({ token: 'pass-1', expiresIn: 300_000 }))
|
||||
.mockRejectedValueOnce(new TypeError('Failed to fetch'))
|
||||
.mockResolvedValueOnce(new Response(null, { status: 502 }));
|
||||
restore = () => fetchSpy.mockRestore();
|
||||
const store = createSearchPassStore(directSearch);
|
||||
await store.requestPass();
|
||||
|
||||
expect(await search(store)).toEqual({ type: 'route', reason: '502' });
|
||||
expect(await search(store)).toEqual({ type: 'route', reason: '502' });
|
||||
expect(fetchSpy.mock.calls.map(([url]) => url)).toEqual([
|
||||
directSearch.passURL,
|
||||
endpoint,
|
||||
proxyURL,
|
||||
]);
|
||||
});
|
||||
|
||||
it('stays on the route for the rest of the page after a 403', async () => {
|
||||
const { authorizations, fetchSpy } = mockFetch([403]);
|
||||
restore = () => fetchSpy.mockRestore();
|
||||
|
||||
@@ -32,6 +32,11 @@ type DirectSearchOutcome =
|
||||
| { type: 'results'; results: OrderedComputedResult[] }
|
||||
| { type: 'route'; reason?: string };
|
||||
|
||||
type SearchAttempt =
|
||||
| { type: 'success'; body: string }
|
||||
| { type: 'http'; response: Response }
|
||||
| { type: 'failure'; reason: 'network' | 'timeout' };
|
||||
|
||||
export type SearchPassStore = ReturnType<typeof createSearchPassStore>;
|
||||
|
||||
/**
|
||||
@@ -39,6 +44,7 @@ export type SearchPassStore = ReturnType<typeof createSearchPassStore>;
|
||||
*/
|
||||
export function createSearchPassStore(directSearch: DirectSearchProps | undefined) {
|
||||
let state: SearchPassState = { status: 'none' };
|
||||
let useProxy = false;
|
||||
let pendingRequest: Promise<void> | null = null;
|
||||
|
||||
const sendPassRequest = async () => {
|
||||
@@ -77,7 +83,9 @@ export function createSearchPassStore(directSearch: DirectSearchProps | undefine
|
||||
(current.status === 'none' && current.reason === '401') ||
|
||||
(current.status === 'ready' && current.replacesRejectedPass),
|
||||
};
|
||||
ReactDOM.preconnect(directSearch.apiURL, { crossOrigin: 'anonymous' });
|
||||
if (!useProxy) {
|
||||
ReactDOM.preconnect(directSearch.apiURL, { crossOrigin: 'anonymous' });
|
||||
}
|
||||
} else if (current.status === 'ready') {
|
||||
state = { status: 'none' };
|
||||
}
|
||||
@@ -146,78 +154,130 @@ export function createSearchPassStore(directSearch: DirectSearchProps | undefine
|
||||
return { type: 'results', results: [] };
|
||||
}
|
||||
|
||||
const { token, replacesRejectedPass } = state;
|
||||
const { apiURL, organizationId, siteId } = directSearch;
|
||||
// A request dropped on the way to the API never settles, so it gets its own time limit.
|
||||
// The browser targets predate `AbortSignal.any`.
|
||||
const request = new AbortController();
|
||||
if (signal.aborted) {
|
||||
request.abort();
|
||||
let pass = state;
|
||||
const { apiURL, organizationId, siteId, proxyURL } = directSearch;
|
||||
const usingProxy = useProxy && Boolean(proxyURL);
|
||||
let url = `${apiURL}/v1/orgs/${organizationId}/sites/${siteId}/search`;
|
||||
if (usingProxy && proxyURL) {
|
||||
url = proxyURL;
|
||||
}
|
||||
signal.addEventListener('abort', () => request.abort(), { once: true });
|
||||
const timeout = setTimeout(() => request.abort(), DIRECT_SEARCH_TIMEOUT_MS);
|
||||
let response: Response;
|
||||
try {
|
||||
response = await fetch(`${apiURL}/v1/orgs/${organizationId}/sites/${siteId}/search`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(toSearchSiteContentBody(query, scope, searchId)),
|
||||
credentials: 'omit',
|
||||
signal: request.signal,
|
||||
});
|
||||
} catch (error) {
|
||||
if (signal.aborted) {
|
||||
throw error;
|
||||
const body = JSON.stringify(toSearchSiteContentBody(query, scope, searchId));
|
||||
let attempt = await sendSearch(url, usingProxy, pass.token, body, signal);
|
||||
|
||||
if (attempt.type === 'failure' && !usingProxy && proxyURL) {
|
||||
const current = state as SearchPassState;
|
||||
if (current.status === 'ready') {
|
||||
useProxy = true;
|
||||
pass = current;
|
||||
attempt = await sendSearch(proxyURL, true, pass.token, body, signal);
|
||||
} else if (current.status === 'none') {
|
||||
useProxy = true;
|
||||
return { type: 'route', reason: attempt.reason };
|
||||
}
|
||||
return fallBack(request.signal.aborted ? 'timeout' : 'network');
|
||||
}
|
||||
|
||||
if (response.status === 401) {
|
||||
return replacesRejectedPass ? fallBack('401') : dropPass(token, '401');
|
||||
if (attempt.type === 'failure') {
|
||||
const current = state as SearchPassState;
|
||||
if (current.status === 'route') {
|
||||
return waitForCooldown(current, signal);
|
||||
}
|
||||
return fallBack(attempt.reason);
|
||||
}
|
||||
if (response.status === 429) {
|
||||
state = {
|
||||
status: 'route',
|
||||
reason: '429',
|
||||
cooldownUntil: Date.now() + getRateLimitWaitMs(response),
|
||||
};
|
||||
return waitForCooldown(state, signal);
|
||||
}
|
||||
if (!response.ok) {
|
||||
if (attempt.type === 'http') {
|
||||
const { response } = attempt;
|
||||
if (response.status === 401) {
|
||||
if (pass.replacesRejectedPass) {
|
||||
return fallBack('401');
|
||||
}
|
||||
return dropPass(pass.token, '401');
|
||||
}
|
||||
if (response.status === 429) {
|
||||
state = {
|
||||
status: 'route',
|
||||
reason: '429',
|
||||
cooldownUntil: Date.now() + getRateLimitWaitMs(response),
|
||||
};
|
||||
return waitForCooldown(state, signal);
|
||||
}
|
||||
return fallBack(String(response.status));
|
||||
}
|
||||
|
||||
let results: OrderedComputedResult[] | null;
|
||||
try {
|
||||
const { items } = (await response.json()) as {
|
||||
const { items } = JSON.parse(attempt.body) as {
|
||||
items: (SearchSpaceResult | SearchRecordResult)[];
|
||||
};
|
||||
const linker = createSiteLinker(directSearch.linker);
|
||||
results = computePublishedSearchResults({
|
||||
let linker = createSiteLinker(directSearch.linker);
|
||||
if (asEmbeddable) {
|
||||
linker = getEmbeddableLinker(linker);
|
||||
}
|
||||
const results = computePublishedSearchResults({
|
||||
asEmbeddable,
|
||||
linker: asEmbeddable ? getEmbeddableLinker(linker) : linker,
|
||||
linker,
|
||||
searchResults: items,
|
||||
spaces: directSearch.spaces,
|
||||
});
|
||||
} catch (error) {
|
||||
if (signal.aborted) {
|
||||
throw error;
|
||||
if (!results) {
|
||||
return { type: 'route', reason: 'unknown_space' };
|
||||
}
|
||||
return fallBack(request.signal.aborted ? 'timeout' : 'invalid');
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
return { type: 'results', results };
|
||||
} catch {
|
||||
return fallBack('invalid');
|
||||
}
|
||||
|
||||
// An unmapped space can come from a structure change after page load; fall back for this query only.
|
||||
return results ? { type: 'results', results } : { type: 'route', reason: 'unknown_space' };
|
||||
};
|
||||
|
||||
return { requestPass, search };
|
||||
}
|
||||
|
||||
async function sendSearch(
|
||||
url: string,
|
||||
useProxy: boolean,
|
||||
token: string,
|
||||
body: string,
|
||||
signal: AbortSignal
|
||||
): Promise<SearchAttempt> {
|
||||
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
|
||||
let mode: RequestMode | undefined;
|
||||
if (useProxy) {
|
||||
mode = 'same-origin';
|
||||
headers['x-gitbook-search-pass'] = token;
|
||||
} else {
|
||||
headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
const request = new AbortController();
|
||||
const abort = () => request.abort();
|
||||
if (signal.aborted) {
|
||||
abort();
|
||||
}
|
||||
signal.addEventListener('abort', abort, { once: true });
|
||||
const timeout = setTimeout(abort, DIRECT_SEARCH_TIMEOUT_MS);
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body,
|
||||
credentials: 'omit',
|
||||
mode,
|
||||
signal: request.signal,
|
||||
});
|
||||
if (!response.ok) {
|
||||
return { type: 'http', response };
|
||||
}
|
||||
return { type: 'success', body: await response.text() };
|
||||
} catch (error) {
|
||||
if (signal.aborted) {
|
||||
throw error;
|
||||
}
|
||||
if (request.signal.aborted) {
|
||||
return { type: 'failure', reason: 'timeout' };
|
||||
}
|
||||
return { type: 'failure', reason: 'network' };
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
signal.removeEventListener('abort', abort);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hold a search until a short rate limit cooldown ends, then send it to the route.
|
||||
* During a longer cooldown the search fails at once, as the route would.
|
||||
|
||||
@@ -132,9 +132,13 @@ export function getDirectSearchProps(context: GitBookSiteContext): DirectSearchP
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const { organizationId, siteId } = context.directSearch;
|
||||
return {
|
||||
...context.directSearch,
|
||||
spaces: getSearchSpaceLookup(context.structure),
|
||||
passURL: context.linker.toPathInSite('~gitbook/search-pass'),
|
||||
proxyURL: context.linker.toPathInSite(
|
||||
`~gitbook/search-direct/orgs/${organizationId}/sites/${siteId}`
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, mock } from 'bun:test';
|
||||
|
||||
import type { RevisionPageDocument, SiteRedirectDestination } from '@gitbook/api';
|
||||
import type { RevisionPageDocument } from '@gitbook/api';
|
||||
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
|
||||
@@ -23,28 +23,15 @@ const page = {
|
||||
|
||||
describe('resolveMissingPagePath', () => {
|
||||
function createRedirectContext(options: {
|
||||
siteRedirect?: {
|
||||
source?: string;
|
||||
target: string;
|
||||
permanent?: boolean;
|
||||
destination?: SiteRedirectDestination;
|
||||
};
|
||||
siteRedirect?: { source?: string; target: string; permanent?: boolean };
|
||||
spaceRedirectPageId?: string;
|
||||
contextId?: string;
|
||||
structure?: GitBookSiteContext['structure'];
|
||||
revisionsBySpace?: Record<string, RevisionPageDocument[]>;
|
||||
}) {
|
||||
const getSiteRedirectBySource = mock(async ({ source }: { source: string }) =>
|
||||
options.siteRedirect && source === (options.siteRedirect.source ?? '/old')
|
||||
? {
|
||||
data: {
|
||||
target: options.siteRedirect.target,
|
||||
redirect: {
|
||||
permanent: options.siteRedirect.permanent ?? false,
|
||||
...(options.siteRedirect.destination
|
||||
? { destination: options.siteRedirect.destination }
|
||||
: {}),
|
||||
},
|
||||
redirect: { permanent: options.siteRedirect.permanent ?? false },
|
||||
},
|
||||
}
|
||||
: { error: { code: 404, message: 'Not found' } }
|
||||
@@ -54,35 +41,19 @@ describe('resolveMissingPagePath', () => {
|
||||
? { data: { id: options.spaceRedirectPageId } }
|
||||
: { error: { code: 404, message: 'Not found' } }
|
||||
);
|
||||
const getRevision = mock(async ({ spaceId }: { spaceId: string }) =>
|
||||
options.revisionsBySpace?.[spaceId]
|
||||
? { data: { pages: options.revisionsBySpace[spaceId] } }
|
||||
: { error: { code: 404, message: 'Not found' } }
|
||||
);
|
||||
|
||||
const defaultSiteSpace = {
|
||||
id: 'site-space-1',
|
||||
space: { id: 'space-1', revision: 'revision-1' },
|
||||
};
|
||||
|
||||
return {
|
||||
organizationId: 'org-1',
|
||||
site: { id: 'site-1' },
|
||||
siteSpace: defaultSiteSpace,
|
||||
structure: options.structure ?? {
|
||||
type: 'siteSpaces',
|
||||
structure: [defaultSiteSpace],
|
||||
},
|
||||
space: { id: 'space-1', revision: 'revision-1' },
|
||||
revisionId: 'revision-1',
|
||||
revision: { pages: [page] },
|
||||
contextId: options.contextId,
|
||||
linker: {
|
||||
toPathInSpace: (path: string) => path,
|
||||
toRelativePathInSite: (path: string) => path,
|
||||
toLinkForContent: (url: string) => new URL(url).pathname,
|
||||
},
|
||||
dataFetcher: { getSiteRedirectBySource, getRevisionPageByPath, getRevision },
|
||||
dataFetcher: { getSiteRedirectBySource, getRevisionPageByPath },
|
||||
} as unknown as GitBookSiteContext;
|
||||
}
|
||||
|
||||
@@ -116,224 +87,6 @@ describe('resolveMissingPagePath', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('ignores a site redirect that targets the current path', async () => {
|
||||
const context = createRedirectContext({
|
||||
siteRedirect: {
|
||||
source: '/release-notes/restricted',
|
||||
target: 'https://docs.example.com/release-notes/restricted',
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'release-notes/restricted')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a site redirect that targets the current path with trailing slash, case, or query differences', async () => {
|
||||
const context = createRedirectContext({
|
||||
siteRedirect: {
|
||||
source: '/release-notes/restricted',
|
||||
target: 'https://docs.example.com/Release-Notes/Restricted/?tab=1#top',
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'release-notes/restricted')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a space-relative redirect that resolves back to the current section path', async () => {
|
||||
const context = {
|
||||
...createRedirectContext({
|
||||
siteRedirect: {
|
||||
source: '/v3/getting-started',
|
||||
target: 'https://docs.example.com/docs/v3/getting-started',
|
||||
},
|
||||
}),
|
||||
linker: createLinker({
|
||||
host: 'docs.example.com',
|
||||
siteBasePath: '/',
|
||||
spaceBasePath: '/docs/',
|
||||
}),
|
||||
} as unknown as GitBookSiteContext;
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'v3/getting-started')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a site redirect targeting a hidden site space on an adaptive site', async () => {
|
||||
const context = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
siteRedirect: {
|
||||
source: '/getting-started',
|
||||
target: 'https://docs.example.com/docs/v3/getting-started',
|
||||
destination: {
|
||||
kind: 'site-page',
|
||||
siteSpaceId: 'site-space-hidden',
|
||||
pageId: 'page-v3',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'getting-started')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a site redirect targeting a hidden section on an adaptive site', async () => {
|
||||
const context = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
structure: {
|
||||
type: 'sections',
|
||||
structure: [
|
||||
{
|
||||
object: 'site-section',
|
||||
id: 'section-visible',
|
||||
siteSpaces: [
|
||||
{
|
||||
id: 'site-space-1',
|
||||
space: { id: 'space-1', revision: 'revision-1' },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
} as unknown as GitBookSiteContext['structure'],
|
||||
siteRedirect: {
|
||||
source: '/old-section',
|
||||
target: 'https://docs.example.com/hidden-section',
|
||||
destination: {
|
||||
kind: 'site-section',
|
||||
siteSectionId: 'section-hidden',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'old-section')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a site redirect targeting a hidden page in the current space on an adaptive site', async () => {
|
||||
const context = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
siteRedirect: {
|
||||
source: '/release-notes/restricted.html',
|
||||
target: 'https://docs.example.com/release-notes/restricted',
|
||||
destination: {
|
||||
kind: 'site-page',
|
||||
siteSpaceId: 'site-space-1',
|
||||
pageId: 'hidden-page',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
await resolveMissingPagePath(context, 'release-notes/restricted.html')
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it('checks target page visibility in another accessible space on an adaptive site', async () => {
|
||||
const otherSpace = {
|
||||
id: 'site-space-2',
|
||||
space: { id: 'space-2', revision: 'revision-2' },
|
||||
};
|
||||
const structure = {
|
||||
type: 'siteSpaces',
|
||||
structure: [
|
||||
{ id: 'site-space-1', space: { id: 'space-1', revision: 'revision-1' } },
|
||||
otherSpace,
|
||||
],
|
||||
} as unknown as GitBookSiteContext['structure'];
|
||||
|
||||
const hiddenContext = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
structure,
|
||||
revisionsBySpace: { 'space-2': [] },
|
||||
siteRedirect: {
|
||||
source: '/old',
|
||||
target: 'https://docs.example.com/other/secret',
|
||||
destination: {
|
||||
kind: 'site-page',
|
||||
siteSpaceId: 'site-space-2',
|
||||
pageId: 'page-secret',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(await resolveMissingPagePath(hiddenContext, 'old')).toBeUndefined();
|
||||
|
||||
const visibleContext = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
structure,
|
||||
revisionsBySpace: { 'space-2': [{ ...page, id: 'page-secret', path: 'secret' }] },
|
||||
siteRedirect: {
|
||||
source: '/old',
|
||||
target: 'https://docs.example.com/other/secret',
|
||||
destination: {
|
||||
kind: 'site-page',
|
||||
siteSpaceId: 'site-space-2',
|
||||
pageId: 'page-secret',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(await resolveMissingPagePath(visibleContext, 'old')).toEqual({
|
||||
type: 'redirect',
|
||||
destination: '/other/secret',
|
||||
permanent: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('ignores a site redirect targeting the reassigned default variant path of the current space', async () => {
|
||||
const context = {
|
||||
...createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
siteRedirect: {
|
||||
source: '/guide/missing',
|
||||
target: 'https://docs.example.com/guide/v3/missing',
|
||||
destination: {
|
||||
kind: 'site-space',
|
||||
siteSpaceId: 'site-space-v3',
|
||||
},
|
||||
},
|
||||
structure: {
|
||||
type: 'sections',
|
||||
structure: [
|
||||
{
|
||||
object: 'site-section',
|
||||
id: 'section-guide',
|
||||
siteSpaces: [
|
||||
{
|
||||
id: 'site-space-v3',
|
||||
path: 'v3',
|
||||
default: true,
|
||||
space: { id: 'space-v3', revision: 'revision-1' },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
} as unknown as GitBookSiteContext['structure'],
|
||||
}),
|
||||
siteSpace: {
|
||||
id: 'site-space-v3',
|
||||
path: 'v3',
|
||||
default: true,
|
||||
space: { id: 'space-v3', revision: 'revision-1' },
|
||||
},
|
||||
linker: createLinker({
|
||||
host: 'docs.example.com',
|
||||
siteBasePath: '/',
|
||||
spaceBasePath: '/guide/',
|
||||
}),
|
||||
} as unknown as GitBookSiteContext;
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'missing')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('keeps a redirect whose current path contains a literal question mark', async () => {
|
||||
const context = createRedirectContext({
|
||||
siteRedirect: {
|
||||
source: '/foo/bar%3Fbaz',
|
||||
target: 'https://docs.example.com/foo/bar',
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'foo/bar?baz')).toEqual({
|
||||
type: 'redirect',
|
||||
destination: '/foo/bar',
|
||||
permanent: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('resolves a space redirect to a page', async () => {
|
||||
const context = createRedirectContext({ spaceRedirectPageId: page.id });
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { permanentRedirect, redirect } from 'next/navigation';
|
||||
|
||||
import {
|
||||
type RevisionPageDocument,
|
||||
type SiteRedirect,
|
||||
SITE_REDIRECT_SOURCE_PATH_MAX_LENGTH,
|
||||
SITE_REDIRECT_SOURCE_PATH_PATTERN,
|
||||
} from '@gitbook/api';
|
||||
@@ -11,12 +10,7 @@ import { type GitBookSiteContext, fetchSiteContextForSiteSpace } from '@/lib/con
|
||||
import { getDataOrNull } from '@/lib/data';
|
||||
import { type ResolvedPagePath, resolvePageId } from '@/lib/pages';
|
||||
import { withLeadingSlash } from '@/lib/paths';
|
||||
import {
|
||||
findSiteSpaceBy,
|
||||
findSiteSpaceByUrl,
|
||||
getSiteStructureSections,
|
||||
resolveSiteSpacePagePath,
|
||||
} from '@/lib/sites';
|
||||
import { findSiteSpaceByUrl, resolveSiteSpacePagePath } from '@/lib/sites';
|
||||
|
||||
const MAX_PAGE_URL_REDIRECTS = 5;
|
||||
|
||||
@@ -119,14 +113,6 @@ export async function resolveMissingPagePath(
|
||||
.filter((source) => SITE_REDIRECT_SOURCE_PATH_REGEX.test(source))
|
||||
);
|
||||
|
||||
const currentPath = linker.toPathInSpace(redirectPathname);
|
||||
let currentPathWithDefaultVariant: string | null = null;
|
||||
if (context.siteSpace.default && context.siteSpace.path) {
|
||||
currentPathWithDefaultVariant = linker.toPathInSpace(
|
||||
`/${context.siteSpace.path}${redirectPathname}`
|
||||
);
|
||||
}
|
||||
|
||||
for (const source of redirectSources) {
|
||||
// We try to resolve the site redirect
|
||||
const resolvedSiteRedirect =
|
||||
@@ -140,18 +126,6 @@ export async function resolveMissingPagePath(
|
||||
})
|
||||
));
|
||||
if (resolvedSiteRedirect) {
|
||||
const destination = linker.toLinkForContent(resolvedSiteRedirect.target);
|
||||
// Skip self-redirects (including default-variant canonical aliases) and hidden adaptive targets.
|
||||
const targetsCurrentPath =
|
||||
isSameRedirectPath(currentPath, destination) ||
|
||||
(currentPathWithDefaultVariant !== null &&
|
||||
isSameRedirectPath(currentPathWithDefaultVariant, destination));
|
||||
if (
|
||||
targetsCurrentPath ||
|
||||
!(await isRedirectDestinationAccessible(context, resolvedSiteRedirect.redirect))
|
||||
) {
|
||||
break;
|
||||
}
|
||||
const isPublicLiveContext =
|
||||
!shareKey &&
|
||||
!context.changeRequest &&
|
||||
@@ -160,7 +134,7 @@ export async function resolveMissingPagePath(
|
||||
!context.isLoggedInVisitor;
|
||||
return {
|
||||
type: 'redirect',
|
||||
destination,
|
||||
destination: linker.toLinkForContent(resolvedSiteRedirect.target),
|
||||
permanent: Boolean(
|
||||
resolvedSiteRedirect.redirect?.permanent &&
|
||||
!resolvedSiteRedirect.redirect.draft &&
|
||||
@@ -228,17 +202,6 @@ export async function resolveSitePageFromURL(
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isSameRedirectPath(currentPath: string, destination: string): boolean {
|
||||
if (!destination.startsWith('/') || destination.startsWith('//')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const destinationPathname = new URL(destination, 'https://gitbook.invalid').pathname;
|
||||
return (
|
||||
normalizeRedirectPathname(currentPath) === normalizeRedirectPathname(destinationPathname)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a pathname into a candidate source for site redirect matching.
|
||||
* The pathname is already percent-encoded, so each segment is decoded before being encoded
|
||||
@@ -263,60 +226,6 @@ function safeDecodeURIComponent(segment: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
async function isRedirectDestinationAccessible(
|
||||
context: GitBookSiteContext,
|
||||
siteRedirect: SiteRedirect | null
|
||||
): Promise<boolean> {
|
||||
if (!context.contextId || !siteRedirect?.destination) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const { destination } = siteRedirect;
|
||||
switch (destination.kind) {
|
||||
case 'external':
|
||||
return true;
|
||||
case 'site-section':
|
||||
return getSiteStructureSections(context.structure, { ignoreGroups: true }).some(
|
||||
(section) => section.id === destination.siteSectionId
|
||||
);
|
||||
case 'site-space':
|
||||
return Boolean(
|
||||
findSiteSpaceBy(context.structure, (entry) => entry.id === destination.siteSpaceId)
|
||||
);
|
||||
case 'site-page': {
|
||||
const target = findSiteSpaceBy(
|
||||
context.structure,
|
||||
(entry) => entry.id === destination.siteSpaceId
|
||||
);
|
||||
if (!target) {
|
||||
return false;
|
||||
}
|
||||
if (destination.siteSpaceId === context.siteSpace.id) {
|
||||
return Boolean(resolvePageId(context.revision.pages, destination.pageId));
|
||||
}
|
||||
const targetRevision = await getDataOrNull(
|
||||
context.dataFetcher.getRevision({
|
||||
spaceId: target.siteSpace.space.id,
|
||||
revisionId: target.siteSpace.space.revision,
|
||||
})
|
||||
);
|
||||
if (!targetRevision) {
|
||||
return false;
|
||||
}
|
||||
return Boolean(resolvePageId(targetRevision.pages, destination.pageId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeRedirectPathname(pathname: string): string {
|
||||
const normalized = pathname
|
||||
.split('/')
|
||||
.filter(Boolean)
|
||||
.map((segment) => safeDecodeURIComponent(segment).toLowerCase())
|
||||
.join('/');
|
||||
return `/${normalized}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page path from the params.
|
||||
*/
|
||||
|
||||
@@ -35,61 +35,4 @@ describe('#enrichFilesystem', () => {
|
||||
expect(paths['/a'].get['x-gitbook-description-html']).toBe('<p>constructor</p>');
|
||||
expect(paths['/b'].get['x-gitbook-description-html']).toBe('<p>constructor</p>');
|
||||
});
|
||||
|
||||
async function enrichSchemas(schemas: Record<string, unknown>) {
|
||||
const { filesystem } = await parseOpenAPI({
|
||||
value: JSON.stringify({
|
||||
openapi: '3.0.0',
|
||||
info: { title: 'Test', version: '1.0.0' },
|
||||
paths: {},
|
||||
components: { schemas },
|
||||
}),
|
||||
rootURL: null,
|
||||
});
|
||||
const enriched = await enrichFilesystem(filesystem);
|
||||
return enriched[0]?.specification.components.schemas;
|
||||
}
|
||||
|
||||
it('drops description fields supplied by the specification', async () => {
|
||||
const schemas = await enrichSchemas({
|
||||
Pet: {
|
||||
type: 'object',
|
||||
'x-gitbook-description-html': '<b>spec</b>',
|
||||
'x-gitbook-description-document': { nodes: [] },
|
||||
},
|
||||
});
|
||||
expect(schemas.Pet['x-gitbook-description-html']).toBeUndefined();
|
||||
expect(schemas.Pet['x-gitbook-description-document']).toBeUndefined();
|
||||
});
|
||||
|
||||
it('sanitizes descriptions of schemas named example', async () => {
|
||||
const schemas = await enrichSchemas({
|
||||
example: { type: 'string', description: '<img src=x onerror=alert(1)>' },
|
||||
});
|
||||
const html = schemas.example['x-gitbook-description-html'];
|
||||
expect(html).toContain('<img');
|
||||
expect(html).not.toContain('onerror');
|
||||
});
|
||||
|
||||
it('sanitizes descriptions in example values that could render HTML', async () => {
|
||||
const schemas = await enrichSchemas({
|
||||
Pet: {
|
||||
type: 'object',
|
||||
example: {
|
||||
description: '<img src=x onerror=alert(1)>',
|
||||
'x-gitbook-description-html': '<img src=x onerror=alert(2)>',
|
||||
},
|
||||
},
|
||||
});
|
||||
const html = schemas.Pet.example['x-gitbook-description-html'];
|
||||
expect(html).toBeDefined();
|
||||
expect(html).not.toContain('onerror');
|
||||
});
|
||||
|
||||
it('keeps example values without HTML as written', async () => {
|
||||
const schemas = await enrichSchemas({
|
||||
Pet: { type: 'object', example: { description: 'A **good** dog' } },
|
||||
});
|
||||
expect(schemas.Pet.example).toEqual({ description: 'A **good** dog' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,21 +8,19 @@ import { parseMarkdown } from '../markdown';
|
||||
export async function enrichFilesystem(filesystem: Filesystem) {
|
||||
const parseMarkdownWithCache = createMarkdownParser();
|
||||
return traverse(filesystem, async (node, path) => {
|
||||
// Examples included: a `$ref` can render an example value as a schema.
|
||||
delete node['x-gitbook-description-html'];
|
||||
delete node['x-gitbook-description-document'];
|
||||
|
||||
if (
|
||||
path !== undefined &&
|
||||
'description' in node &&
|
||||
typeof node.description === 'string' &&
|
||||
node.description
|
||||
) {
|
||||
const description = node.description.trim();
|
||||
// Examples stay as written, except where their raw description could render a tag.
|
||||
const isExample = path[path.length - 1] === 'example';
|
||||
if (description && (!isExample || description.includes('<'))) {
|
||||
node['x-gitbook-description-html'] = await parseMarkdownWithCache(description);
|
||||
const key = path[path.length - 1];
|
||||
// Avoid parsing descriptions in examples.
|
||||
if (key !== 'example') {
|
||||
const description = node.description.trim();
|
||||
if (description) {
|
||||
node['x-gitbook-description-html'] = await parseMarkdownWithCache(description);
|
||||
}
|
||||
}
|
||||
}
|
||||
return node;
|
||||
|
||||
@@ -41,6 +41,7 @@ export type DirectSearchProps = {
|
||||
apiURL: string;
|
||||
organizationId: string;
|
||||
siteId: string;
|
||||
proxyURL?: string;
|
||||
linker: SiteLinkerInput;
|
||||
spaces: SearchSpaceLookup;
|
||||
/** Site route that hands out a search pass. */
|
||||
|
||||
@@ -157,8 +157,7 @@ export async function serveProxyAnalyticsEvent(req: Request) {
|
||||
/**
|
||||
* Extract the real IP address of the client from the request headers, accounting for various proxies and CDNs.
|
||||
*/
|
||||
|
||||
function getXForwardedFor(headers: Headers): string | null {
|
||||
export function getXForwardedFor(headers: Headers): string | null {
|
||||
// We start first with the cloudflare headers
|
||||
if (headers.has('cf-connecting-ip')) {
|
||||
return headers.get('cf-connecting-ip');
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test';
|
||||
import { NextRequest } from 'next/server';
|
||||
|
||||
import { middleware } from './middleware';
|
||||
import { GITBOOK_API_URL } from '@/lib/env';
|
||||
import { removeTrailingSlash } from '@/lib/paths';
|
||||
|
||||
const PATH = '/~gitbook/search-direct/orgs/org_1/sites/site-1';
|
||||
const PASS_HEADER = 'x-gitbook-search-pass';
|
||||
const SEARCH_PASS =
|
||||
'eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwidHlwIjoic2l0ZS1zZWFyY2gtcGFzcytqd3QifQ..AAAAAAAAAAAAAAAA.AAAA.AAAAAAAAAAAAAAAAAAAAAA';
|
||||
|
||||
let fetchSpy: ReturnType<typeof spyOn<typeof globalThis, 'fetch'>>;
|
||||
|
||||
beforeEach(() => {
|
||||
fetchSpy = spyOn(globalThis, 'fetch').mockImplementation(async () => new Response(null));
|
||||
});
|
||||
|
||||
afterEach(() => fetchSpy.mockRestore());
|
||||
|
||||
describe('direct site search middleware', () => {
|
||||
it.each([
|
||||
['https://hosted.gitbook.io', '', ''],
|
||||
['https://proxy.gitbook.site', '/sites/site-1', '/'],
|
||||
])('forwards a search from %s%s%s directly to GBX', async (host, prefix, suffix) => {
|
||||
fetchSpy.mockResolvedValueOnce(
|
||||
Response.json(
|
||||
{ items: [] },
|
||||
{
|
||||
status: 429,
|
||||
headers: {
|
||||
'cache-control': 'public, max-age=600',
|
||||
'set-cookie': 'upstream=1',
|
||||
'retry-after': '3',
|
||||
'x-ratelimit-scope': 'site',
|
||||
'x-ratelimit-reset': '123',
|
||||
},
|
||||
}
|
||||
)
|
||||
);
|
||||
const body = '{"query":"tokens"}';
|
||||
const request = new NextRequest('https://origin.example.com/ignored?ignored=1', {
|
||||
method: 'POST',
|
||||
body: new TextEncoder().encode(body),
|
||||
headers: {
|
||||
'x-gitbook-url': `${host}${prefix}${PATH}${suffix}?also-ignored=1`,
|
||||
'x-gitbook-url-signature': 'internal',
|
||||
'x-gitbook-ip': '192.0.2.1',
|
||||
'cf-connecting-ip': '192.0.2.2',
|
||||
'x-forwarded-for': '192.0.2.3',
|
||||
[PASS_HEADER]: SEARCH_PASS,
|
||||
cookie: 'session=1',
|
||||
authorization: 'Bearer incoming-token',
|
||||
},
|
||||
});
|
||||
const response = await middleware(request);
|
||||
|
||||
expect(fetchSpy).toHaveBeenCalledTimes(1);
|
||||
const [url, init] = fetchSpy.mock.calls[0] ?? [];
|
||||
expect(String(url)).toBe(
|
||||
`${removeTrailingSlash(GITBOOK_API_URL)}/v1/orgs/org_1/sites/site-1/search`
|
||||
);
|
||||
expect(init).toMatchObject({ method: 'POST', redirect: 'manual', duplex: 'half' });
|
||||
expect(init?.body).toBe(request.body);
|
||||
expect(await new Response(init?.body).text()).toBe(body);
|
||||
expect(Object.fromEntries(new Headers(init?.headers))).toEqual({
|
||||
authorization: `Bearer ${SEARCH_PASS}`,
|
||||
'content-type': 'application/json',
|
||||
'x-forwarded-for': '192.0.2.1',
|
||||
});
|
||||
expect(response.status).toBe(429);
|
||||
expect(response.headers.get('cache-control')).toBe('no-store');
|
||||
expect(response.headers.get('set-cookie')).toBeNull();
|
||||
expect(response.headers.get('retry-after')).toBe('3');
|
||||
expect(response.headers.get('x-ratelimit-scope')).toBe('site');
|
||||
expect(response.headers.get('x-ratelimit-reset')).toBe('123');
|
||||
expect(await response.text()).toBe('{"items":[]}');
|
||||
});
|
||||
|
||||
it.each([
|
||||
['wrong method', 'GET', PATH, '', 405],
|
||||
['missing pass', 'POST', PATH, '', 401],
|
||||
['personal token', 'POST', PATH, 'personal-api-token', 401],
|
||||
['signed API token', 'POST', PATH, 'eyJhbGciOiJIUzI1NiJ9.e30.c2ln', 401],
|
||||
['invalid organization ID', 'POST', PATH.replace('org_1', 'org%20bad'), SEARCH_PASS, 400],
|
||||
['invalid site ID', 'POST', PATH.replace('site-1', 'site.bad'), SEARCH_PASS, 400],
|
||||
] as const)('rejects %s', async (_name, method, path, pass, status) => {
|
||||
const headers = new Headers({ 'x-forwarded-host': 'docs.example.com' });
|
||||
if (pass) {
|
||||
headers.set(PASS_HEADER, pass);
|
||||
}
|
||||
const response = await middleware(
|
||||
new NextRequest(`https://origin.example.com${path}`, { method, headers })
|
||||
);
|
||||
|
||||
expect(response.status).toBe(status);
|
||||
expect(response.headers.get('cache-control')).toBe('no-store');
|
||||
expect(fetchSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('returns an uncached 502 when the upstream request fails', async () => {
|
||||
fetchSpy.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
||||
const response = await middleware(
|
||||
new NextRequest(`https://origin.example.com${PATH}`, {
|
||||
method: 'POST',
|
||||
headers: { 'x-forwarded-host': 'docs.example.com', [PASS_HEADER]: SEARCH_PASS },
|
||||
})
|
||||
);
|
||||
|
||||
expect(response.status).toBe(502);
|
||||
expect(response.headers.get('cache-control')).toBe('no-store');
|
||||
expect(fetchSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
|
||||
import {
|
||||
type ServerInsightsEventInput,
|
||||
getXForwardedFor,
|
||||
serveProxyAnalyticsEvent,
|
||||
trackServerInsightsEvents,
|
||||
} from './lib/tracking';
|
||||
@@ -37,7 +38,12 @@ import {
|
||||
normalizeRequestURL,
|
||||
throwIfDataError,
|
||||
} from '@/lib/data';
|
||||
import { GITBOOK_DISABLE_INSIGHTS, isGitBookAssetsHostURL, isGitBookHostURL } from '@/lib/env';
|
||||
import {
|
||||
GITBOOK_API_URL,
|
||||
GITBOOK_DISABLE_INSIGHTS,
|
||||
isGitBookAssetsHostURL,
|
||||
isGitBookHostURL,
|
||||
} from '@/lib/env';
|
||||
import { getImageResizingContextId } from '@/lib/images';
|
||||
import { isAITrainingOrIndexingRequest } from '@/lib/indexing-crawlers';
|
||||
import { getLogger } from '@/lib/logger';
|
||||
@@ -86,10 +92,19 @@ export const config = {
|
||||
type URLWithMode = { url: URL; mode: 'url' | 'url-host' };
|
||||
|
||||
const REVISION_ROBOTS_TAG = 'noindex, nofollow';
|
||||
const DIRECT_SEARCH_PATH = /\/~gitbook\/search-direct\/orgs\/([^/]*)\/sites\/([^/]*)\/?$/;
|
||||
const DIRECT_SEARCH_ID = /^[a-zA-Z0-9_-]+$/;
|
||||
const DIRECT_SEARCH_PASS =
|
||||
/^[a-zA-Z0-9_-]+\.\.[a-zA-Z0-9_-]{16}\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]{22}$/;
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
try {
|
||||
const requestURL = new URL(request.url);
|
||||
const siteURL = getSiteURLFromRequest(request);
|
||||
const directSearch = siteURL?.url.pathname.match(DIRECT_SEARCH_PATH);
|
||||
if (directSearch) {
|
||||
return await serveDirectSearch(request, directSearch[1], directSearch[2]);
|
||||
}
|
||||
|
||||
// Reject malicious requests
|
||||
const rejectResponse = await validateServerActionRequest(request);
|
||||
@@ -97,14 +112,10 @@ export async function middleware(request: NextRequest) {
|
||||
return rejectResponse;
|
||||
}
|
||||
|
||||
for (const handler of [serveSiteRoutes, serveSpacePDFRoutes]) {
|
||||
const result = await handler(requestURL, request);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
const siteResponse = await serveSiteRoutes(requestURL, request, siteURL);
|
||||
return (
|
||||
siteResponse ?? (await serveSpacePDFRoutes(requestURL, request)) ?? NextResponse.next()
|
||||
);
|
||||
} catch (error) {
|
||||
return serveErrorResponse(error as Error);
|
||||
}
|
||||
@@ -164,8 +175,7 @@ function shouldFilterMaliciousRequests(requestURL: URL): boolean {
|
||||
/**
|
||||
* Handle request that are targetting the site routes group.
|
||||
*/
|
||||
async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
|
||||
const match = getSiteURLFromRequest(request);
|
||||
async function serveSiteRoutes(requestURL: URL, request: NextRequest, match: URLWithMode | null) {
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
@@ -183,6 +193,53 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
|
||||
return response;
|
||||
}
|
||||
|
||||
async function serveDirectSearch(request: NextRequest, organizationId = '', siteId = '') {
|
||||
const responseHeaders = new Headers({ 'Cache-Control': 'no-store' });
|
||||
if (request.method !== 'POST') {
|
||||
responseHeaders.set('Allow', 'POST');
|
||||
return new Response(null, { status: 405, headers: responseHeaders });
|
||||
}
|
||||
if (!DIRECT_SEARCH_ID.test(organizationId) || !DIRECT_SEARCH_ID.test(siteId)) {
|
||||
return new Response(null, { status: 400, headers: responseHeaders });
|
||||
}
|
||||
const pass = request.headers.get('x-gitbook-search-pass');
|
||||
if (!pass || !DIRECT_SEARCH_PASS.test(pass)) {
|
||||
return new Response(null, { status: 401, headers: responseHeaders });
|
||||
}
|
||||
|
||||
const headers = new Headers({
|
||||
Authorization: `Bearer ${pass}`,
|
||||
'Content-Type': request.headers.get('Content-Type') ?? 'application/json',
|
||||
});
|
||||
const ip = request.headers.get('x-gitbook-ip') ?? getXForwardedFor(request.headers);
|
||||
if (ip) headers.set('X-Forwarded-For', ip);
|
||||
|
||||
const upstream = await fetch(
|
||||
`${removeTrailingSlash(GITBOOK_API_URL)}/v1/orgs/${organizationId}/sites/${siteId}/search`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: request.body,
|
||||
redirect: 'manual',
|
||||
signal: request.signal,
|
||||
duplex: 'half',
|
||||
} as RequestInit
|
||||
).catch(() => {
|
||||
getLogger().subLogger('directSiteSearch').warn('Direct search upstream failed', {
|
||||
status: 502,
|
||||
organizationId,
|
||||
siteId,
|
||||
});
|
||||
return new Response(null, { status: 502 });
|
||||
});
|
||||
for (const name of ['Content-Type', 'Retry-After', 'X-RateLimit-Scope', 'X-RateLimit-Reset']) {
|
||||
const value = upstream.headers.get(name);
|
||||
if (value !== null) responseHeaders.set(name, value);
|
||||
}
|
||||
const responseBody = await upstream.arrayBuffer();
|
||||
return new Response(responseBody, { status: upstream.status, headers: responseHeaders });
|
||||
}
|
||||
|
||||
async function serveSiteRequest(requestURL: URL, request: NextRequest, match: URLWithMode) {
|
||||
const { url: siteRequestURL, mode } = match;
|
||||
|
||||
|
||||
@@ -94,17 +94,6 @@ describe('servePageMarkdown', () => {
|
||||
expect(response.headers.get('Location')).toBe('/docs/new-page.md');
|
||||
});
|
||||
|
||||
it('returns not-found markdown instead of looping when a site redirect targets the same markdown path', async () => {
|
||||
const context = createContext({
|
||||
siteRedirect: { target: 'https://docs.example.com/docs/old-page.md', permanent: false },
|
||||
});
|
||||
|
||||
const response = await servePageMarkdown(context, 'old-page');
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(await response.text()).toContain('# Page Not Found');
|
||||
});
|
||||
|
||||
it('redirects to the markdown version of a space redirect target', async () => {
|
||||
const context = createContext({ spaceRedirectPageId: page.id });
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { RevisionPageDocument, RevisionPageGroup } from '@gitbook/api';
|
||||
|
||||
import { isSameRedirectPath, resolveMissingPagePath } from '@/components/SitePage/fetch';
|
||||
import { resolveMissingPagePath } from '@/components/SitePage/fetch';
|
||||
import { isAIEnabled } from '@/components/utils/isAIChatEnabled';
|
||||
import { renderPageAgentInstructions, renderQueryingDocumentation } from '@/lib/ask-prompt';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
@@ -38,15 +38,10 @@ export async function servePageMarkdown(baseContext: GitBookSiteContext, pagePat
|
||||
if (!pageLookup) {
|
||||
const fallback = await resolveMissingPagePath(baseContext, pagePath);
|
||||
if (fallback?.type === 'redirect') {
|
||||
const destination = toMarkdownDestination(fallback.destination);
|
||||
if (
|
||||
!isSameRedirectPath(
|
||||
context.linker.toPathForPagePath({ path: pagePath }),
|
||||
destination
|
||||
)
|
||||
) {
|
||||
return markdownRedirect(destination, fallback.permanent);
|
||||
}
|
||||
return markdownRedirect(
|
||||
toMarkdownDestination(fallback.destination),
|
||||
fallback.permanent
|
||||
);
|
||||
}
|
||||
if (fallback?.type === 'page') {
|
||||
return markdownRedirect(
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
# @gitbook/icons
|
||||
|
||||
## 0.6.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 9fcde5f: Add a `@gitbook/icons/validateIconName` entry that validates icon names without loading the icon labels and search terms.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 265ca4b: Add a skip link, keyboard navigation between content tabs, focusable table of contents toggles, and hide decorative icons from assistive technologies.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"version": "0.6.0",
|
||||
"version": "0.5.0",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
||||
"@gitbook/fontawesome-pro": "1.0.23"
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
# @gitbook/react-contentkit
|
||||
|
||||
## 0.7.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [9fcde5f]
|
||||
- Updated dependencies [265ca4b]
|
||||
- @gitbook/icons@0.6.0
|
||||
|
||||
## 0.7.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@gitbook/react-contentkit",
|
||||
"version": "0.7.19",
|
||||
"version": "0.7.18",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
# @gitbook/react-openapi
|
||||
|
||||
## 2.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 262749a: Copy the current spec's server in OpenAPI endpoint URLs instead of a server kept from a previously visited page.
|
||||
|
||||
## 2.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.1",
|
||||
"sideEffects": false,
|
||||
"dependencies": {
|
||||
"@base-ui/react": "catalog:",
|
||||
|
||||
Reference in New Issue
Block a user