Compare commits

...

4 Commits

Author SHA1 Message Date
github-actions[bot] 59d6a57111 Version Packages 2026-11-24 21:46:50 +00:00
Steven H 7f08fb14d1 Read site revision previews through the site revision endpoints (#4818)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 21:46:02 +00:00
Nolann B. 867da7b94c Resolve GitBook links in OpenAPI schema descriptions to the site's URLs (#4838) 2026-11-24 19:32:47 +01:00
Peter White 76e1abd7e1 Use the default scope for legacy search links (#4837) 2026-11-24 11:54:25 +01:00
80 changed files with 813 additions and 395 deletions
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Keep links in generated Markdown usable outside the source page.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Handle optional emoji and icon values when rendering tags.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Point agents to the site MCP server from Markdown pages, the page HTML, llms.txt and llms-full.txt.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Serve the site AI Catalog as specification version 0.9, with identifiers in its `urn:air:{publisher}:{name}:{kind}` format.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Fade the bottom of collapsed code blocks so readers can tell there is more code, matching the editor.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Answer Assistant questions with medium reasoning instead of low, matching AI search.
-5
View File
@@ -1,5 +0,0 @@
---
"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.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Bump `@opennextjs/aws` to 4.2.0 and `@opennextjs/cloudflare` to 1.20.18.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Fix horizontal page scroll caused by card carousels bleeding past the viewport.
-5
View File
@@ -1,5 +0,0 @@
---
"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.
-6
View File
@@ -1,6 +0,0 @@
---
"@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.
@@ -1,6 +0,0 @@
---
"@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.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Reduce the wait after typing in site search to 100 ms.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Fix the table of contents keeping published pages busy in older Chrome versions such as Chrome 130.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Fix `'use cache'` entries never being stored in or read from R2 and the regional cache on Cloudflare.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Remove duplicated declarations from the global stylesheet.
@@ -1,5 +0,0 @@
---
"@gitbook/icons": minor
---
Add a `@gitbook/icons/validateIconName` entry that validates icon names without loading the icon labels and search terms.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Keep inline code and highlighted text readable when a paragraph crosses the bottom edge of a background page cover.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Keep published pages available when an integration block needs its connection or settings checked.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Keep published site search results visible while visitors refine a query.
@@ -1,6 +0,0 @@
---
"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.
-5
View File
@@ -1,5 +0,0 @@
---
"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.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Load the OpenAPI stylesheet only on pages with OpenAPI blocks.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Render the llms.txt directive as the first element in the page body so agents find it before the navigation.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Count only MCP tool calls in the MCP request insights event.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Answer GET requests to the MCP endpoint with an `Allow: POST` header.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Challenge MCP clients to authorize again when a visitor-auth site rejects their bearer token.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Support MCP protocol version 2025-11-25 on published site MCP servers.
@@ -1,5 +0,0 @@
---
"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.
@@ -1,5 +0,0 @@
---
"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.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Keep published revision URLs out of search results.
@@ -1,5 +0,0 @@
---
"@gitbook/react-openapi": patch
---
Copy the current spec's server in OpenAPI endpoint URLs instead of a server kept from a previously visited page.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Publish an OpenSearch description on every site so browsers can offer its search from the address bar.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Show H3 headings in the page outline.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Render a page's search keywords in its metadata.
-5
View File
@@ -1,5 +0,0 @@
---
"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.
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Respect disabled change request previews on published sites.
-5
View File
@@ -1,5 +0,0 @@
---
"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.
@@ -1,5 +0,0 @@
---
"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.
@@ -1,6 +0,0 @@
---
"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.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Send only the site origin as referrer to third parties, and only let the embedding page open the embed messaging channel.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Remove the ChatGPT-specific plain text response for Markdown and llms.txt routes; these now always serve `text/markdown`.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Track the displayed position and search request ID when a visitor opens a search result.
-5
View File
@@ -1,5 +0,0 @@
---
"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.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Include navigation-hidden published spaces in direct browser search lookup and avoid latching on unknown spaces.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Send each search once on sites without a top header, and make search work between 768 and 1023 px wide.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Show loading rows shaped like search results while search waits for the server.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Show search results with one-line breadcrumbs and no icons or shortcut hints, and select the result under the mouse.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Stop caching site search results in the framework cache, so every search reaches the API.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Show one server-ordered search list and open its top result on Enter.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Load the data of the page actions menu from the menu itself, so it can be cached apart from the page body.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Follow the API's cache lifetime for site data, so a site preview shows layout changes soon after they are saved.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Render small cards in a responsive four-column grid and carousel.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Ignore tag category references when displaying assigned tags and update filters.
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Update the GitBook API SDK for site revision responses.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Fix wide content in Updates blocks overflowing into the page outline.
+32 -32
View File
@@ -49,7 +49,7 @@
},
"packages/embed": {
"name": "@gitbook/embed",
"version": "0.7.0",
"version": "0.8.0",
"dependencies": {
"@gitbook/api": "catalog:",
"bidc": "catalog:",
@@ -109,7 +109,7 @@
},
"packages/gitbook": {
"name": "gitbook",
"version": "0.28.2",
"version": "0.29.0",
"dependencies": {
"@base-ui/react": "catalog:",
"@cloudflare/workers-types": "^4.20251011.0",
@@ -228,7 +228,7 @@
},
"packages/icons": {
"name": "@gitbook/icons",
"version": "0.5.0",
"version": "0.6.0",
"bin": {
"gitbook-icons": "./bin/gitbook-icons.js",
},
@@ -266,7 +266,7 @@
},
"packages/react-contentkit": {
"name": "@gitbook/react-contentkit",
"version": "0.7.18",
"version": "0.7.19",
"dependencies": {
"@gitbook/api": "catalog:",
"@gitbook/icons": "workspace:*",
@@ -309,7 +309,7 @@
},
"packages/react-openapi": {
"name": "@gitbook/react-openapi",
"version": "2.0.1",
"version": "2.0.2",
"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.93.0", "", { "os": "android", "cpu": "arm" }, "sha512-KKw70pbD5Pvq3G2lJ+WQ71XPMjCmg37rkSe2+mDqCRP3PoTSdDMuEi4UOnE8JBtyNM7bek61EC2s0Jt7S7u+Sg=="],
"@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-arm64": ["@oxlint/binding-android-arm64@1.93.0", "", { "os": "android", "cpu": "arm64" }, "sha512-fvr1fTUZGelwRxKDt64pf28aL1WaWgviwz3X+E/FcRYvrlEahH0NECRz/c1SY+K+KWmZk5uAf6h1kQnyBkp/2A=="],
"@oxlint/binding-android-arm64": ["@oxlint/binding-android-arm64@1.95.0", "", { "os": "android", "cpu": "arm64" }, "sha512-uAIGZQ9uJVUeogeWOSboI3F7twOuM4mNuZcHXD9+LdYLcWp7J6kbtRUXJ6GVqcs5E0Cjb4emmSBK9FNrkGuhqQ=="],
"@oxlint/binding-darwin-arm64": ["@oxlint/binding-darwin-arm64@1.93.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-VdvSN9JRf4Es6ZzoAdvEeh8tgKdw8L4H82WmA8MMPVfPdZGCwE/nI27Z1HrRHYQhPxOh4kmnxQEioSUFrOvDaw=="],
"@oxlint/binding-darwin-arm64": ["@oxlint/binding-darwin-arm64@1.95.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Ogh1vfHO5vshKRop/He46r+WqC5BTqonYwhB4fp9e2gvOFvg1Xi6XsHTuM/lBSH85ZcaG+DS99EMAy9GcwDong=="],
"@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-darwin-x64": ["@oxlint/binding-darwin-x64@1.95.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-kTrE1xfpQUBMMS50Ws6KY92N8OsJ8LE6JqxKqkHEY3KdsmguQ6kKVGSjzyt1HLwsSi0fQCvNRog8YRBBovD1AA=="],
"@oxlint/binding-freebsd-x64": ["@oxlint/binding-freebsd-x64@1.93.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-jDfIbi30zZaKi+rTvig3sge+Xhi8pFFSgHxb0jzovc4qh8ETm/irKV9c7N/JsuwnYc5sbvf4IC8w1vQQ0IL+BA=="],
"@oxlint/binding-freebsd-x64": ["@oxlint/binding-freebsd-x64@1.95.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-ho7E1VCInK0VnpneRaI1BEpe1ceJE8VjxP2O9THWdReV6bth1Q4+80kYVGGK47mHRyZ2NGztQZ2dWRo6j1lavA=="],
"@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-gnueabihf": ["@oxlint/binding-linux-arm-gnueabihf@1.95.0", "", { "os": "linux", "cpu": "arm" }, "sha512-94afnouMHcnHr/OtRh07gG5LehC9M0GjiSoik3xxTtrmq6cWxXOTAhYlBtxa67u/GlycbnHlDoGJfYlTshcr/w=="],
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/binding-linux-arm-musleabihf@1.93.0", "", { "os": "linux", "cpu": "arm" }, "sha512-5pJ9NjMvH7WMUqXB6bTTOSemBm39w2cod27Hu3+Yom/GhbTeNXlYcpDx1o4CgBP6fhp0YHG66TNdVaUm6sHjsA=="],
"@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-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-gnu": ["@oxlint/binding-linux-arm64-gnu@1.95.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-EpXpEQKmgtkvc6RyU84LM1e3CrVDWQkgghVzf1hMGgwjBzgKAJ/QntHgnzmu5cNeLBfa7GPCY+gGXxEll8Adcg=="],
"@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-arm64-musl": ["@oxlint/binding-linux-arm64-musl@1.95.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-+96Md8c2BAgFp8nWHrUrpqba87DoU+HVJYIun6qA+QKFoeNd3xAWq1JYE6da4nVli9GgwRpfncfRePcgmQQaIQ=="],
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/binding-linux-ppc64-gnu@1.93.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-7qKCnvhZKDXJG2pdbLazd2hw4FxjJHbZOFrrbzyy5PdHfPLH9vnNUa1le01A8uItZuYKPBPncH+HCoEiFT4SgA=="],
"@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-riscv64-gnu": ["@oxlint/binding-linux-riscv64-gnu@1.93.0", "", { "os": "linux", "cpu": "none" }, "sha512-2pgulxC6G8V5wE750NJE/fRkf9aO6i6yoj10wyaR2EdiNtan4OemsOtsQ0ZTXGdY8Q3IoTmlND3GYvjJsvikYg=="],
"@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-musl": ["@oxlint/binding-linux-riscv64-musl@1.93.0", "", { "os": "linux", "cpu": "none" }, "sha512-yWsn6Gg2PnGG5jlyDz5+pHGiMTMiy4adaa4WRMzDgzB8efaShk1JMmTHIBSVLQMh0tYXRs4CN5uJCO79r4Mi4g=="],
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/binding-linux-riscv64-musl@1.95.0", "", { "os": "linux", "cpu": "none" }, "sha512-ceRx+K2WJ7C3tIv+XjZS28oAoZ7DY29ZcWChPdXG5M100phI72FRDYwGRlWZEeDfmkROnarLTMKnnrQAtsC42Q=="],
"@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-s390x-gnu": ["@oxlint/binding-linux-s390x-gnu@1.95.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-WbD3sM08ZDk2QE6060wK/omihQKbRm+LVzKIg4W5zNTbEhYJChciqX49UZuqW59RGF+wBUxzAup7egUIESTjUA=="],
"@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-gnu": ["@oxlint/binding-linux-x64-gnu@1.95.0", "", { "os": "linux", "cpu": "x64" }, "sha512-F4ST2ZkFIiLL9OKyRCyC0KQQpwM5WIv0GTcMiZuYVa6xSRJHR05iVRqst+arOVudEPkhP47EnbuoC9UfVCYDyg=="],
"@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.93.0", "", { "os": "linux", "cpu": "x64" }, "sha512-plf5DE2objcG8Tf7mXRuRa8tT8rzDkpjqXQtKoGsKHWkpgsialbON1+cCtoSEUTVbQUjXvuAm8vV9+3rR0yCBw=="],
"@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.95.0", "", { "os": "linux", "cpu": "x64" }, "sha512-hEpYDZatpuxLrWlTlkwhHZ1e8QkL02aFS55BPQX1XA9iOd+yUEADGFF1iY6z+xkw6RkpzXFrtnDFe4/JNOLSRA=="],
"@oxlint/binding-openharmony-arm64": ["@oxlint/binding-openharmony-arm64@1.93.0", "", { "os": "none", "cpu": "arm64" }, "sha512-Kp2yJrKvoTe9FfKdO/xwLNUbs2bYTMKx0+aoQD1s0h/Tx0kSgtHSdGmrk8tTKdluosjFbo88qYRIaNIX43AfFw=="],
"@oxlint/binding-openharmony-arm64": ["@oxlint/binding-openharmony-arm64@1.95.0", "", { "os": "none", "cpu": "arm64" }, "sha512-+JwIH9/uLgQXfxBvOAKzvp616m5i0fBR5ELEBHm5D+++fStBZ+74T7YW4xBpX13zNU2blr52Swoe3GTF1JyqRg=="],
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/binding-win32-arm64-msvc@1.93.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-vigjcHCFsR6KjnWTEVfaCxcMYapEuaK9FZa1MpewwQ1S+Xud3v0okfkj1RySsD6RF1NRHIjSlQSalTnKIaj3nA=="],
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/binding-win32-arm64-msvc@1.95.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-pzJgcp3WkOSchukg5y5pn5mVIQ6P83RDI79YJ9gQZKed1pOgjhrmlc5AMizjuq6/P8VifhxzBsMqYI6LLjO2TA=="],
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/binding-win32-ia32-msvc@1.93.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-0Ot3BEe/AAr2/uQhe55r8CmPlperYk2mQmxdutOru7oU0kir6IiEVHb1TG3GORRlfra97lPHVDLhgmihiKzLrg=="],
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/binding-win32-ia32-msvc@1.95.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-54MeQvLRXkJqF1nEFs7wb73SrnurZJQy9fVK4NdEwumNKVwyUUxpGHhvfDMIY2NqJZS7kz0pY9uVty5664Gt1Q=="],
"@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.93.0", "", { "os": "win32", "cpu": "x64" }, "sha512-ZzzIIVs/Qkm8trUWYKF0OYub5ALlv50/3gsEZbKAvWgz+yNJX6uRmQ8ySPXU2Q0/Y9m4JCOjhpmC8XUYbPHX5Q=="],
"@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.95.0", "", { "os": "win32", "cpu": "x64" }, "sha512-I/Fn+Fed1qzb1k2uRjMe2VRtRN1+ZObyU+E76B6v/Ul3Z6JdeAW5zBHSe0n5d8a0ZyU4iorzVy0Rw9LYgo3MSQ=="],
"@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.11", "", { "os": "darwin", "cpu": "x64" }, "sha512-HMMeUIEAsmyIbSYn1ySvF/4gGMa0joiTMq4dQDuloIAnOpbtFT3JEiVsYnASdTWDXvplbRbZlqjU1EBeSR9G1A=="],
"@turbo/darwin-64": ["@turbo/darwin-64@2.11.13", "", { "os": "darwin", "cpu": "x64" }, "sha512-5IT29i4j55E5O66+la7L8Y46ut7dFaNZqrgUIYYNtcpMt9Ql7aYnSQb/6tZ+prE2AfX1RBCAtRJE41txS2rG3w=="],
"@turbo/darwin-arm64": ["@turbo/darwin-arm64@2.11.11", "", { "os": "darwin", "cpu": "arm64" }, "sha512-+8iySNgqYWY6PZYUQzYu6zn0C04z2OEq1vQ6oMGsJ9sxN6wOpg1gzi1AJ5VKDHviWvMUjhqng51hTEQZOuiqYQ=="],
"@turbo/darwin-arm64": ["@turbo/darwin-arm64@2.11.13", "", { "os": "darwin", "cpu": "arm64" }, "sha512-YFJPayVNlhSPRIZSeERiZYGKKqPs6N6qGhim8J3GtBdv5ZjUNF1ixfnAAyCVTqFEnMSkn1W7F0Y07kca8EjWsg=="],
"@turbo/linux-64": ["@turbo/linux-64@2.11.11", "", { "os": [ "linux", "android", ], "cpu": "x64" }, "sha512-uImTKFYCFKsoFxjaXeJXlMPv4uU3OIIDjyzoIwYVqOtu9LnCZ/5/fzu/WP6+G9YfwGAPRplTHkKFfcI5t97RGw=="],
"@turbo/linux-64": ["@turbo/linux-64@2.11.13", "", { "os": [ "linux", "android", ], "cpu": "x64" }, "sha512-R5RIQflV4ffBDNuUwjmtmzIr6Y2UeyeeHTtultYF7cnFn3tG1RZ4GRBlpjUhHB6JxuR7l1B450hlbzdtlD3ghg=="],
"@turbo/linux-arm64": ["@turbo/linux-arm64@2.11.11", "", { "os": [ "linux", "android", ], "cpu": "arm64" }, "sha512-Y7xffSVfyyYRGzNy6PLdrFL4xXN6iTuR3W0SyJvH/yd3d4defA6dansZwJpPDVnIpD8a2Qn256DwY/Qin4Ip4g=="],
"@turbo/linux-arm64": ["@turbo/linux-arm64@2.11.13", "", { "os": [ "linux", "android", ], "cpu": "arm64" }, "sha512-AwV8pVO/cH/lwx1B7SGfzUA/3e6vmPaygFp9NOSRESs6t3Wr63zrBuXlluDogAOIxIMlHDB2ZbBueDsBnQxh2Q=="],
"@turbo/windows-64": ["@turbo/windows-64@2.11.11", "", { "os": "win32", "cpu": "x64" }, "sha512-e2WqNtkPGo3QDwNNwwBo89Dx3PtSJ9Wp9QuRNzn80rrRnSHB+1mfBMZTpdHjA8/G/sG9rl76TdWdpgVsimjRdg=="],
"@turbo/windows-64": ["@turbo/windows-64@2.11.13", "", { "os": "win32", "cpu": "x64" }, "sha512-PGXYTaFaN3FZloe4RffNGJmfB+TIWlqQgKK1PVyKwPN+PUzxGa+byxHBWFHredMaVbnUc6L/F6/QR4iHyM/wug=="],
"@turbo/windows-arm64": ["@turbo/windows-arm64@2.11.11", "", { "os": "win32", "cpu": "arm64" }, "sha512-LURivfmgv34Osm8NR1gZGx4vdlux9KAgRM+FoooXNG0838ff0+akWZ76iPSke0NS2rsf7Z4Gw+YSaygzNTZuRA=="],
"@turbo/windows-arm64": ["@turbo/windows-arm64@2.11.13", "", { "os": "win32", "cpu": "arm64" }, "sha512-YdRHWstBUHWt/eChOEM4f9LT0dPiWK5SNgtV77bLCr3JNke9M5E7metqelNYj+tXe36dH0BZrk2CMnFlWqHKng=="],
"@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.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=="],
"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=="],
"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.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=="],
"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=="],
"type": ["type@2.7.3", "", {}, "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ=="],
+2 -2
View File
@@ -7,8 +7,8 @@
"devDependencies": {
"@changesets/cli": "^2.31.1",
"oxfmt": "^0.62.0",
"oxlint": "^1.93.0",
"turbo": "^2.11.11",
"oxlint": "^1.95.0",
"turbo": "^2.11.13",
"vercel": "50.37.3"
},
"packageManager": "bun@1.3.7",
+11
View File
@@ -1,5 +1,16 @@
# @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
+1 -1
View File
@@ -13,7 +13,7 @@
}
},
"sideEffects": false,
"version": "0.7.0",
"version": "0.8.0",
"license": "Apache-2.0",
"dependencies": {
"@gitbook/api": "catalog:",
+75
View File
@@ -1,5 +1,80 @@
# 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.
- 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`.
- 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
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook",
"version": "0.28.2",
"version": "0.29.0",
"private": true,
"dependencies": {
"@base-ui/react": "catalog:",
@@ -14,6 +14,11 @@ export async function hasContentBeenUpdated(props: { revisionId: string }) {
const context = await getServerActionBaseContext();
const siteURLData = await getSiteURLDataFromMiddleware();
// A site revision never changes what it shows.
if (siteURLData.siteRevision) {
return false;
}
if (siteURLData.changeRequest) {
const changeRequest = await getDataOrNull(
context.dataFetcher.getChangeRequest({
@@ -15,8 +15,6 @@ export function computeRemoteSearchScope(
}
switch (scope) {
case 'all':
return { mode: 'all' };
case 'default':
return { mode: 'current', siteSpaceId };
case 'extended':
@@ -1,6 +1,13 @@
import { describe, expect, it } from 'bun:test';
import { NuqsTestingAdapter } from 'nuqs/adapters/testing';
import { createElement } from 'react';
import { renderToString } from 'react-dom/server';
import { shouldKeepSearchState } from './useSearch';
import { SearchContextProvider, shouldKeepSearchState, useSearchState } from './useSearch';
function SearchScopeValue() {
return useSearchState()?.scope ?? null;
}
describe('shouldKeepSearchState', () => {
it('discards an empty default search state', () => {
@@ -23,3 +30,25 @@ describe('shouldKeepSearchState', () => {
).toBe(true);
});
});
it.each([
['scope=all', 'default'],
['global=true', 'default'],
['scope=current&global=true', 'current'],
['scope=extended&global=true', 'extended'],
])('resolves %s to %s for a linked search', (params, scope) => {
const search = createElement(
SearchContextProvider,
{ prewarmURL: '/~gitbook/search' },
createElement(SearchScopeValue)
);
expect(
renderToString(
createElement(NuqsTestingAdapter, {
searchParams: `q=setup&${params}`,
children: search,
})
)
).toBe(scope);
});
@@ -1,12 +1,6 @@
'use client';
import {
type Values,
parseAsBoolean,
parseAsString,
parseAsStringLiteral,
useQueryStates,
} from 'nuqs';
import { type Values, parseAsString, parseAsStringLiteral, useQueryStates } from 'nuqs';
import React from 'react';
import type { LinkProps } from '../primitives';
@@ -16,8 +10,6 @@ import { useSearchPrewarm } from './useSearchPrewarm';
import type { DirectSearchProps } from '@/lib/search-results';
export type SearchScope =
/** Search all content on the site */
| 'all'
/** Search the current section's variant + matched/default variant for other sections */
| 'default'
/** Search all variants of the current section */
@@ -41,9 +33,8 @@ export interface SearchState {
const keyMap = {
q: parseAsString,
ask: parseAsString,
scope: parseAsStringLiteral(['all', 'default', 'extended', 'current']).withDefault('default'),
scope: parseAsStringLiteral(['default', 'extended', 'current']).withDefault('default'),
section: parseAsString,
global: parseAsBoolean, // Legacy support for global=true
};
export type UpdateSearchState = (
@@ -62,11 +53,6 @@ function normalizeRawState(values: Values<typeof keyMap>) {
if (values.ask === 'true' && values.q) {
return { ...values, q: null, ask: values.q };
}
// Handle legacy global=true
if (values.global === true) {
return { ...values, scope: 'all' as const, global: null };
}
return values;
}
+28 -2
View File
@@ -44,6 +44,7 @@ import {
getLinkerForSiteSpace,
getLocalizedTitle,
getSiteStructureSections,
listAllSiteSpaces,
} from '@/lib/sites';
/**
@@ -57,8 +58,6 @@ export type SiteURLData = Pick<
| 'site'
| 'siteSpace'
| 'space'
| 'revision'
| 'changeRequest'
| 'shareKey'
| 'siteSection'
| 'siteBasePath'
@@ -71,6 +70,14 @@ export type SiteURLData = Pick<
*/
imagesContextId: string;
/**
* Space revision, change request or site revision the URL previews: at most one is set. The
* middleware reads them from the resolved content, which types them as exclusive.
*/
revision?: string;
changeRequest?: string;
siteRevision?: string;
/**
* Whether this request is a fallback rendering.
* We use this when switching variant as we don't know if the page exists in the other variant.
@@ -217,6 +224,9 @@ export type GitBookSiteContext = GitBookSpaceContext & {
/** Whether search indexation is blocked for this deployment. */
noIndexSearch: boolean;
/** Site revision the URL previews. Content is read as it pins it. */
siteRevision?: string;
/** Whether the request included a visitor token. */
isLoggedInVisitor: boolean;
@@ -250,6 +260,13 @@ export function getBaseContext(input: {
const dataFetcher = createDataFetcher({
apiToken: siteURLData.apiToken ?? null,
siteRevision: siteURLData.siteRevision
? {
organizationId: siteURLData.organization,
siteId: siteURLData.site,
siteRevisionId: siteURLData.siteRevision,
}
: undefined,
});
const linkerInput: SiteLinkerInput = {
@@ -305,6 +322,7 @@ export async function fetchSiteContextByURLLookup(
contextId: data.contextId,
isFallback: data.isFallback ?? false,
noIndexSearch: data.noIndexSearch ?? false,
siteRevision: data.siteRevision,
isLoggedInVisitor: data.isLoggedInVisitor ?? false,
preview: data.preview ?? false,
displayAgentInstructions: data.displayAgentInstructions,
@@ -329,6 +347,7 @@ export async function fetchSiteContextByIds(
contextId?: string;
isFallback: boolean;
noIndexSearch: boolean;
siteRevision?: string;
isLoggedInVisitor: boolean;
preview: boolean;
displayAgentInstructions?: boolean;
@@ -462,6 +481,12 @@ export async function fetchSiteContextByIds(
return {
...spaceContext,
// Only the site's own spaces are read at the site revision it previews.
dataFetcher: ids.siteRevision
? spaceContext.dataFetcher.withSiteRevisionSpaces(
listAllSiteSpaces(siteStructure).map((entry) => entry.space.id)
)
: spaceContext.dataFetcher,
locale: siteSpace.space.language ?? spaceContext.locale,
linker: getLinkerForSiteSpace(siteLinker, siteSpace, spaceContext.revision.pages),
organizationId: ids.organization,
@@ -477,6 +502,7 @@ export async function fetchSiteContextByIds(
contextId: ids.contextId,
isFallback: ids.isFallback,
noIndexSearch: ids.noIndexSearch,
siteRevision: ids.siteRevision,
isLoggedInVisitor: ids.isLoggedInVisitor,
preview: ids.preview,
displayAgentInstructions: ids.displayAgentInstructions,
+351 -47
View File
@@ -11,7 +11,7 @@ import { getCacheTag, getComputedContentSourceCacheTags } from '@gitbook/cache-t
import { cache } from '../cache';
import { DataFetcherError, wrapDataFetcherError } from './errors';
import type { GitBookDataFetcher } from './types';
import type { DataFetcherResponse, GitBookDataFetcher } from './types';
import { GITBOOK_API_TOKEN, GITBOOK_API_URL, GITBOOK_USER_AGENT } from '@/lib/env';
import { toSearchSiteContentBody } from '@/lib/search-results';
import { trace } from '@/lib/tracing';
@@ -21,6 +21,25 @@ interface DataFetcherInput {
* API token.
*/
apiToken: string | null;
/**
* Site revision being previewed. The site's spaces and OpenAPI specs are read at it.
*/
siteRevision?: DataFetcherSiteRevision;
}
/**
* A site revision, as a preview URL resolves it.
*/
export interface DataFetcherSiteRevision {
organizationId: string;
siteId: string;
siteRevisionId: string;
/**
* Spaces of the site, read at the site revision. Other spaces are read live. Until the site
* structure is known, every space is read at the site revision.
*/
spaceIds?: string[];
}
/**
@@ -46,10 +65,18 @@ export function createDataFetcher(
withToken({ apiToken }) {
return createDataFetcher({
...input,
apiToken,
});
},
withSiteRevisionSpaces(spaceIds) {
return createDataFetcher({
...input,
siteRevision: input.siteRevision ? { ...input.siteRevision, spaceIds } : undefined,
});
},
//
// API that are tied to the token
//
@@ -77,61 +104,120 @@ export function createDataFetcher(
});
},
getRevision(params) {
return getRevision(input, {
spaceId: params.spaceId,
revisionId: params.revisionId,
metadata: params.metadata ?? false,
});
return readAtSiteRevision(
input,
params.spaceId,
(siteRevisionInput) =>
getRevisionAtSiteRevision(siteRevisionInput, {
spaceId: params.spaceId,
metadata: params.metadata ?? false,
}),
() =>
getRevision(input, {
spaceId: params.spaceId,
revisionId: params.revisionId,
metadata: params.metadata ?? false,
})
);
},
getRevisionPageByPath(params) {
return getRevisionPageByPath(input, {
spaceId: params.spaceId,
revisionId: params.revisionId,
path: params.path,
metadata: params.metadata,
cachedMetadata: params.cachedMetadata,
});
return readAtSiteRevision(
input,
params.spaceId,
(siteRevisionInput) =>
getPageByPathAtSiteRevision(siteRevisionInput, {
spaceId: params.spaceId,
path: params.path,
metadata: params.metadata ?? false,
cachedMetadata: params.cachedMetadata ?? false,
}),
() =>
getRevisionPageByPath(input, {
spaceId: params.spaceId,
revisionId: params.revisionId,
path: params.path,
metadata: params.metadata,
cachedMetadata: params.cachedMetadata,
})
);
},
getRevisionPageMarkdown(params) {
return getRevisionPageMarkdown(
return readAtSiteRevision(
input,
{
spaceId: params.spaceId,
revisionId: params.revisionId,
pageId: params.pageId,
},
// We pass the name of the function to distinguish between cache entries
// By default Next only uses the arguments, the filename and the position of the function inside the file
// By adding a dummy argument with the function name, we can change the order without breaking anything
'getRevisionPageMarkdown'
params.spaceId,
(siteRevisionInput) =>
getPageMarkdownAtSiteRevision(siteRevisionInput, {
spaceId: params.spaceId,
pageId: params.pageId,
}),
() =>
getRevisionPageMarkdown(
input,
{
spaceId: params.spaceId,
revisionId: params.revisionId,
pageId: params.pageId,
},
// We pass the name of the function to distinguish between cache entries
// By default Next only uses the arguments, the filename and the position of the function inside the file
// By adding a dummy argument with the function name, we can change the order without breaking anything
'getRevisionPageMarkdown'
)
);
},
getRevisionPageDocument(params) {
return getRevisionPageDocument(
return readAtSiteRevision(
input,
{
spaceId: params.spaceId,
revisionId: params.revisionId,
pageId: params.pageId,
},
// We pass the name of the function to distinguish between cache entries
// By default Next only uses the arguments, the filename and the position of the function inside the file
// By adding a dummy argument with the function name, we can change the order without breaking anything
'getRevisionPageDocument'
params.spaceId,
(siteRevisionInput) =>
getPageDocumentAtSiteRevision(siteRevisionInput, {
spaceId: params.spaceId,
pageId: params.pageId,
}),
() =>
getRevisionPageDocument(
input,
{
spaceId: params.spaceId,
revisionId: params.revisionId,
pageId: params.pageId,
},
// We pass the name of the function to distinguish between cache entries
// By default Next only uses the arguments, the filename and the position of the function inside the file
// By adding a dummy argument with the function name, we can change the order without breaking anything
'getRevisionPageDocument'
)
);
},
getRevisionReusableContentDocument(params) {
return getRevisionReusableContentDocument(input, {
spaceId: params.spaceId,
revisionId: params.revisionId,
reusableContentId: params.reusableContentId,
});
return readAtSiteRevision(
input,
params.spaceId,
(siteRevisionInput) =>
getReusableContentDocumentAtSiteRevision(siteRevisionInput, {
spaceId: params.spaceId,
reusableContentId: params.reusableContentId,
}),
() =>
getRevisionReusableContentDocument(input, {
spaceId: params.spaceId,
revisionId: params.revisionId,
reusableContentId: params.reusableContentId,
})
);
},
getLatestOpenAPISpecVersionContent(params) {
return getLatestOpenAPISpecVersionContent(input, {
organizationId: params.organizationId,
slug: params.slug,
});
return readAtSiteRevision(
input,
null,
(siteRevisionInput) =>
getOpenAPISpecContentAtSiteRevision(siteRevisionInput, { slug: params.slug }),
() =>
getLatestOpenAPISpecVersionContent(input, {
organizationId: params.organizationId,
slug: params.slug,
})
);
},
getSpace(params) {
return getSpace(input, {
@@ -195,15 +281,233 @@ export function createDataFetcher(
},
listRevisionPageMetaLinks(params) {
return listRevisionPageMetaLinks(input, {
spaceId: params.spaceId,
revisionId: params.revisionId,
pageId: params.pageId,
});
return readAtSiteRevision(
input,
params.spaceId,
(siteRevisionInput) =>
listPageMetaLinksAtSiteRevision(siteRevisionInput, {
spaceId: params.spaceId,
pageId: params.pageId,
}),
() =>
listRevisionPageMetaLinks(input, {
spaceId: params.spaceId,
revisionId: params.revisionId,
pageId: params.pageId,
})
);
},
};
}
/**
* Data fetcher input to read at a site revision. It leaves out the site's space IDs, which only
* choose what to read at the site revision, so they stay out of cache keys.
*/
type SiteRevisionDataFetcherInput = DataFetcherInput & {
siteRevision: Omit<DataFetcherSiteRevision, 'spaceIds'>;
};
/**
* Read content at the site revision of the input, or `live` when there is no site revision or
* for a space outside the site. An OpenAPI spec (no space) is always read at the site revision.
*/
async function readAtSiteRevision<T>(
input: DataFetcherInput,
spaceId: string | null,
atSiteRevision: (input: SiteRevisionDataFetcherInput) => Promise<DataFetcherResponse<T>>,
live: () => Promise<DataFetcherResponse<T>>
): Promise<DataFetcherResponse<T>> {
const { siteRevision } = input;
if (!siteRevision || (spaceId && siteRevision.spaceIds?.includes(spaceId) === false)) {
return live();
}
const { spaceIds: _spaceIds, ...cacheableSiteRevision } = siteRevision;
return atSiteRevision({ ...input, siteRevision: cacheableSiteRevision });
}
// Each read at a site revision sends the same query as its live counterpart.
const getRevisionAtSiteRevision = cache(
async (input: SiteRevisionDataFetcherInput, params: { spaceId: string; metadata: boolean }) => {
'use cache';
return fetchAtSiteRevision(
input,
`getRevisionAtSiteRevision(${params.spaceId})`,
(api, { organizationId, siteId, siteRevisionId }) =>
api.orgs.getRevisionInSiteRevision(
organizationId,
siteId,
siteRevisionId,
params.spaceId,
{ metadata: params.metadata },
{ ...noCacheFetchOptions }
)
);
}
);
const getPageByPathAtSiteRevision = cache(
async (
input: SiteRevisionDataFetcherInput,
params: { spaceId: string; path: string; metadata: boolean; cachedMetadata: boolean }
) => {
'use cache';
return fetchAtSiteRevision(
input,
`getPageByPathAtSiteRevision(${params.spaceId}, ${params.path})`,
(api, { organizationId, siteId, siteRevisionId }) =>
api.orgs.getPageByPathInSiteRevision(
organizationId,
siteId,
siteRevisionId,
params.spaceId,
encodeURIComponent(params.path),
{ metadata: params.metadata, cachedMetadata: params.cachedMetadata },
{ ...noCacheFetchOptions }
)
);
}
);
const getPageMarkdownAtSiteRevision = cache(
async (input: SiteRevisionDataFetcherInput, params: { spaceId: string; pageId: string }) => {
'use cache';
return wrapDataFetcherError(async () => {
return trace(
`getPageMarkdownAtSiteRevision(${params.spaceId}, ${params.pageId})`,
async () => {
const { organizationId, siteId, siteRevisionId } = input.siteRevision;
const res = await apiClient(input).orgs.getPageInSiteRevision(
organizationId,
siteId,
siteRevisionId,
params.spaceId,
params.pageId,
{
format: 'markdown',
'format.markdown.refs': 'stable',
evaluated: 'deterministic-only',
metadata: false,
},
{ ...noCacheFetchOptions }
);
cacheTag(...getCacheTagsFromResponse(res));
cacheLife('max');
if (!('markdown' in res.data)) {
throw new DataFetcherError('Page is not a document', 404);
}
return res.data.markdown;
}
);
});
}
);
const getPageDocumentAtSiteRevision = cache(
async (input: SiteRevisionDataFetcherInput, params: { spaceId: string; pageId: string }) => {
'use cache';
return fetchAtSiteRevision(
input,
`getPageDocumentAtSiteRevision(${params.spaceId}, ${params.pageId})`,
(api, { organizationId, siteId, siteRevisionId }) =>
api.orgs.getPageDocumentInSiteRevision(
organizationId,
siteId,
siteRevisionId,
params.spaceId,
params.pageId,
{ evaluated: 'deterministic-only', dereferenced: 'reusable-contents' },
{ ...noCacheFetchOptions }
)
);
}
);
const getReusableContentDocumentAtSiteRevision = cache(
async (
input: SiteRevisionDataFetcherInput,
params: { spaceId: string; reusableContentId: string }
) => {
'use cache';
return fetchAtSiteRevision(
input,
`getReusableContentDocumentAtSiteRevision(${params.spaceId}, ${params.reusableContentId})`,
(api, { organizationId, siteId, siteRevisionId }) =>
api.orgs.getReusableContentDocumentInSiteRevision(
organizationId,
siteId,
siteRevisionId,
params.spaceId,
params.reusableContentId,
{ evaluated: 'deterministic-only' },
{ ...noCacheFetchOptions }
)
);
}
);
const listPageMetaLinksAtSiteRevision = cache(
async (input: SiteRevisionDataFetcherInput, params: { spaceId: string; pageId: string }) => {
'use cache';
return fetchAtSiteRevision(
input,
`listPageMetaLinksAtSiteRevision(${params.spaceId}, ${params.pageId})`,
(api, { organizationId, siteId, siteRevisionId }) =>
api.orgs.listPageMetaLinksInSiteRevision(
organizationId,
siteId,
siteRevisionId,
params.spaceId,
params.pageId,
{ ...noCacheFetchOptions }
)
);
}
);
const getOpenAPISpecContentAtSiteRevision = cache(
async (input: SiteRevisionDataFetcherInput, params: { slug: string }) => {
'use cache';
return fetchAtSiteRevision(
input,
`getOpenAPISpecContentAtSiteRevision(${params.slug})`,
(api, { organizationId, siteId, siteRevisionId }) =>
api.orgs.getOpenApiSpecContentInSiteRevision(
organizationId,
siteId,
siteRevisionId,
params.slug,
{ ...noCacheFetchOptions }
)
);
}
);
/**
* Fetch from an endpoint at a site revision. What a site revision pins never changes, so the
* response is cached forever.
*/
function fetchAtSiteRevision<T>(
input: SiteRevisionDataFetcherInput,
name: string,
request: (
api: ReturnType<typeof apiClient>,
siteRevision: SiteRevisionDataFetcherInput['siteRevision']
) => Promise<HttpResponse<T, unknown>>
): Promise<DataFetcherResponse<T>> {
return wrapDataFetcherError(async () => {
return trace(name, async () => {
const res = await request(apiClient(input), input.siteRevision);
cacheTag(...getCacheTagsFromResponse(res));
cacheLife('max');
return res.data;
});
});
}
/**
* Infer the cache life from the api response headers.
* @param response The response from the API call.
+6
View File
@@ -51,6 +51,12 @@ export interface GitBookDataFetcher {
*/
withToken(input: { apiToken: string }): GitBookDataFetcher;
/**
* Create a data fetcher that reads only these spaces at the site revision it previews, and
* other spaces live.
*/
withSiteRevisionSpaces(spaceIds: string[]): GitBookDataFetcher;
/**
* Get a user by its ID.
*/
+4 -1
View File
@@ -10,6 +10,7 @@ import {
} from '@gitbook/openapi-parser';
import { enrichFilesystem } from './enrich';
import { resolveOpenAPIDescriptionLinks } from './resolveDescriptionLinks';
import type {
AnyOpenAPIOperationsBlock,
OpenAPISchemasBlock,
@@ -41,7 +42,9 @@ export async function fetchOpenAPIFilesystem(
// If the reference is a new OpenAPI reference, we return it.
if (ref.kind === 'openapi') {
assert(resolved.openapi?.filesystem);
return resolved.openapi.filesystem;
return resolveOpenAPIDescriptionLinks(resolved.openapi.filesystem, (contentRef) =>
resolveContentRef(contentRef, context)
);
}
// For legacy blocks ("swagger"), we need to fetch the file system.
return fetchFilesystem(resolved.href, context.space.id);
@@ -0,0 +1,44 @@
import { describe, expect, it } from 'bun:test';
import { parseOpenAPI } from '@gitbook/openapi-parser';
import { resolveOpenAPIDescriptionLinks } from './resolveDescriptionLinks';
const APP_URL = 'https://app.gitbook.com/s/space-1/tables';
describe('resolveOpenAPIDescriptionLinks', () => {
it('points tagged links at their resolved URL without mutating the input', async () => {
const original =
`<p><a href="${APP_URL}" data-gitbook-ref="/spaces/space-1/pages/page-1">Fields</a>` +
` <a href="${APP_URL}" data-gitbook-ref="/spaces/space-1/pages/missing">Gone</a>` +
' <a href="https://example.com">Docs</a></p>';
const { filesystem } = await parseOpenAPI({
value: JSON.stringify({
openapi: '3.0.0',
info: { title: 'Test', version: '1.0.0' },
paths: {},
components: {
schemas: {
Condition: { type: 'object', 'x-gitbook-description-html': original },
},
},
}),
rootURL: null,
});
const resolved = await resolveOpenAPIDescriptionLinks(filesystem, async (ref) =>
ref.kind === 'page' && ref.page === 'page-1' ? { href: '/docs/tables' } : null
);
expect(resolved[0]?.specification.components?.schemas?.Condition).toMatchObject({
'x-gitbook-description-html':
'<p><a href="/docs/tables" data-gitbook-ref="/spaces/space-1/pages/page-1">Fields</a>' +
` <a href="${APP_URL}" data-gitbook-ref="/spaces/space-1/pages/missing">Gone</a>` +
' <a href="https://example.com">Docs</a></p>',
});
// The spec content comes from the data cache, shared across sites.
expect(filesystem[0]?.specification.components?.schemas?.Condition).toMatchObject({
'x-gitbook-description-html': original,
});
});
});
@@ -0,0 +1,173 @@
import { type DefaultTreeAdapterMap, parseFragment } from 'parse5';
import * as React from 'react';
import type { ContentRef } from '@gitbook/api';
import type { Filesystem, OpenAPIV3xDocument } from '@gitbook/openapi-parser';
import { escapeHTML } from '@/lib/html';
import { resolveStringContentRef } from '@/lib/references';
const DESCRIPTION_HTML_KEY = 'x-gitbook-description-html';
// Slate JSON, which never holds description HTML: skipped to keep the walk short.
const DESCRIPTION_DOCUMENT_KEY = 'x-gitbook-description-document';
// Set by spec processing on links to GitBook content, e.g. `/spaces/{space}/pages/{page}`.
const CONTENT_REF_ATTRIBUTE = 'data-gitbook-ref';
type OpenAPIFilesystem = Filesystem<OpenAPIV3xDocument>;
type ResolveContentRef = (ref: ContentRef) => Promise<{ href: string } | null>;
// Per request: resolved hrefs depend on the site being rendered.
const getResolvedFilesystems = React.cache(
() => new WeakMap<OpenAPIFilesystem, Promise<OpenAPIFilesystem>>()
);
/**
* Point description links that spec processing tagged with a content ref at their URL in the
* current site. Links whose ref doesn't resolve keep the href written in the spec.
* Returns a copy when something changed: the input may be shared through the data cache.
*/
export function resolveOpenAPIDescriptionLinks(
filesystem: OpenAPIFilesystem,
resolveContentRef: ResolveContentRef
): Promise<OpenAPIFilesystem> {
const resolvedFilesystems = getResolvedFilesystems();
let promise = resolvedFilesystems.get(filesystem);
if (!promise) {
promise = baseResolveOpenAPIDescriptionLinks(filesystem, resolveContentRef);
resolvedFilesystems.set(filesystem, promise);
}
return promise;
}
async function baseResolveOpenAPIDescriptionLinks(
filesystem: OpenAPIFilesystem,
resolveContentRef: ResolveContentRef
): Promise<OpenAPIFilesystem> {
// Tagged HTML → its rewritten version, filled in once the refs resolve.
const rewritten = new Map<string, string>();
mapDescriptionHTML(filesystem, (html) => {
if (html.includes(CONTENT_REF_ATTRIBUTE)) {
rewritten.set(html, html);
}
return html;
});
if (rewritten.size === 0) {
return filesystem;
}
const hrefs = new Map<string, Promise<string | null>>();
const resolveHref = (source: string) => {
let href = hrefs.get(source);
if (!href) {
const ref = resolveStringContentRef(source);
href = ref
? resolveContentRef(ref).then((resolved) => resolved?.href ?? null)
: Promise.resolve(null);
hrefs.set(source, href);
}
return href;
};
await Promise.all(
Array.from(rewritten.keys(), async (html) => {
rewritten.set(html, await rewriteLinks(html, resolveHref));
})
);
return mapDescriptionHTML(filesystem, (html) => rewritten.get(html) ?? html);
}
/**
* Replace the href of each tagged link with its resolved URL.
*/
async function rewriteLinks(
html: string,
resolveHref: (source: string) => Promise<string | null>
): Promise<string> {
const fragment = parseFragment(html, { sourceCodeLocationInfo: true });
const replacements: { start: number; end: number; value: string }[] = [];
await Promise.all(
collectLinks(fragment).map(async (link) => {
const source = link.attrs.find((attr) => attr.name === CONTENT_REF_ATTRIBUTE)?.value;
const location = link.sourceCodeLocation?.attrs?.href;
if (!source || !location) {
return;
}
const href = await resolveHref(source);
if (href) {
replacements.push({
start: location.startOffset,
end: location.endOffset,
value: `href="${escapeHTML(href)}"`,
});
}
})
);
// Apply from the end so earlier offsets stay valid.
replacements.sort((a, b) => b.start - a.start);
let result = html;
for (const { start, end, value } of replacements) {
result = result.slice(0, start) + value + result.slice(end);
}
return result;
}
function collectLinks(
node: DefaultTreeAdapterMap['node'],
links: DefaultTreeAdapterMap['element'][] = []
): DefaultTreeAdapterMap['element'][] {
if ('tagName' in node && node.tagName === 'a') {
links.push(node);
}
if ('childNodes' in node) {
for (const child of node.childNodes) {
collectLinks(child, links);
}
}
return links;
}
/**
* Map every description HTML in a JSON value, copying only the objects on a changed path.
*/
function mapDescriptionHTML<T>(value: T, transform: (html: string) => string): T {
if (typeof value !== 'object' || value === null) {
return value;
}
if (Array.isArray(value)) {
let result: unknown[] | null = null;
for (let index = 0; index < value.length; index++) {
const item = value[index];
const next = mapDescriptionHTML(item, transform);
if (next !== item) {
result ??= [...value];
result[index] = next;
}
}
return (result ?? value) as T;
}
const record = value as Record<string, unknown>;
let result: Record<string, unknown> | null = null;
// `for...in` over plain JSON objects: several times faster than `Object.entries` on large specs.
for (const key in record) {
if (key === DESCRIPTION_DOCUMENT_KEY) {
continue;
}
const child = record[key];
const next =
key === DESCRIPTION_HTML_KEY && typeof child === 'string'
? transform(child)
: mapDescriptionHTML(child, transform);
if (next !== child) {
result ??= { ...record };
result[key] = next;
}
}
return (result ?? record) as T;
}
+1
View File
@@ -32,6 +32,7 @@ export function isSiteIndexable(context: GitBookSiteContext) {
if (
context.changeRequest ||
context.siteRevision ||
context.revisionId !== context.space.revision ||
hasRevisionSelector(context.linker.spaceBasePath)
) {
+20 -3
View File
@@ -449,8 +449,7 @@ async function serveSiteRequest(requestURL: URL, request: NextRequest, match: UR
basePath: siteURLData.basePath,
space: siteURLData.space,
organization: siteURLData.organization,
changeRequest: siteURLData.changeRequest,
revision: siteURLData.revision,
...getPreviewedContent(siteURLData),
shareKey: siteURLData.shareKey,
preview: siteURLData.preview,
apiToken: siteURLData.apiToken,
@@ -965,7 +964,7 @@ function encodePathInSiteContent(
siteSpace: siteURLData.siteSpace,
siteShareKey: siteURLData.shareKey,
space: siteURLData.space,
revision: siteURLData.revision,
revision: getPreviewedContent(siteURLData).revision,
displayContext: SiteInsightsDisplayContext.Server,
};
@@ -1229,3 +1228,21 @@ function acceptsMarkdown(request: Request): boolean {
const htmlIndex = mediaTypes.findIndex((type) => type === 'text/html' || type === '*/*');
return htmlIndex === -1 || markdownIndex < htmlIndex;
}
/**
* The revision, change request or site revision a URL previews: at most one of them.
*/
function getPreviewedContent(
content: PublishedSiteContent
): Pick<SiteURLData, 'revision' | 'changeRequest' | 'siteRevision'> {
if ('revision' in content) {
return { revision: content.revision };
}
if ('changeRequest' in content) {
return { changeRequest: content.changeRequest };
}
if ('siteRevision' in content) {
return { siteRevision: content.siteRevision };
}
return {};
}
+10
View File
@@ -1,5 +1,15 @@
# @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
+1 -1
View File
@@ -39,7 +39,7 @@
}
},
"sideEffects": false,
"version": "0.5.0",
"version": "0.6.0",
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^7.2.0",
"@gitbook/fontawesome-pro": "1.0.23"
+8
View File
@@ -1,5 +1,13 @@
# @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 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@gitbook/react-contentkit",
"version": "0.7.18",
"version": "0.7.19",
"type": "module",
"exports": {
".": {
+6
View File
@@ -1,5 +1,11 @@
# @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
+1 -1
View File
@@ -7,7 +7,7 @@
"default": "./dist/index.js"
}
},
"version": "2.0.1",
"version": "2.0.2",
"sideEffects": false,
"dependencies": {
"@base-ui/react": "catalog:",