Compare commits

..

11 Commits

Author SHA1 Message Date
Samy Pessé 3fe3809416 Version Packages (#2415)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-10-24 15:54:23 +02:00
Samy Pessé 363d337a72 Cleanup GitHub workflows (#2554) 2024-10-24 14:50:39 +02:00
Amrit Kahlon f89b31c940 Upgrade to the new scalar client (#2539)
Co-authored-by: Samy Pessé <samypesse@gmail.com>
2024-10-24 14:40:33 +02:00
Samy Pessé 630c3e84dd Migrate to cloudflare/wrangler-action for deployment (#2549) 2024-10-24 14:30:13 +02:00
Samy Pessé d43202f137 Reduce bundle size of shiki (#2551) 2024-10-24 10:16:56 +02:00
Scott Cazan 0964043489 Use updated endpoint for page feedbacks (#2548) 2024-10-24 10:16:46 +02:00
Taran Vohra e9b31a545d Unify section tab styles with page item styles (#2552) 2024-10-24 13:28:15 +05:30
Greg Bergé 7f28a88374 Use transparent bg for secondary button (#2545) 2024-10-24 06:51:39 +02:00
Steven H 07ea45bf84 Remove deprecated synced block from GitBook Open (#2546) 2024-10-23 15:45:31 +01:00
Zeno Kapitein a86d35f721 Fixes variant selector for sites without variants (#2544) 2024-10-22 17:22:07 +02:00
Zeno Kapitein d6c28a0ff6 Update header styling of sections, variant selector, and button links (#2543) 2024-10-22 16:58:27 +02:00
102 changed files with 299 additions and 710 deletions
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Avoid multiple <h1> in the page by using a <div> for the title in the header
-6
View File
@@ -1,6 +0,0 @@
---
'@gitbook/react-openapi': patch
'gitbook': patch
---
Adds content-visibility css property to OpenAPI Operation for better render performance
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/cache-do': minor
---
Experiment with optimizing billable duration in Cloudflare by using multiple RPC sessions instead of one
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Fix scroll position when navigating pages on mobile
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-openapi': minor
---
Add Python support in Code Samples
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Add automatic color contrast in site header, restyle search button
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
RND-3532: drop down menu for hidden links at small screen size
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Change dark mode shadow for multi-space search toolbar
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Use ellipsis and fix icon color for more links in the header on small screen
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Improve consistency of change request preview by removing cache-control on response
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/icons': patch
---
Update version for static assets to fix invalid caching
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Revalidate change request cached content when pressing refresh button
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/icons': patch
---
Fix first run of the package in development mode
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Add navigation tabs for sections
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Improve performances of loading pages with embeds by caching them
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-openapi': patch
---
bump: scalar from 1.0.5 to 1.0.7
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Support resolution of new site URLs with sections
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Replace all icons, previously imported from Geist, by new package `@gitbook/icons`
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/cache-do': minor
---
First version of a new cache backend powered by Cloudflare Durable Objects
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Add support for Norwegian language
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Optimize layout shift while transitioning between pages with full width blocks (ex: OpenAPI blocks)
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Add support for page icons
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Fix GitBook specific static assets not being served correctly when deployed on Cloudflare
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Only display spaces dropdown in compact header when site is multi-variants
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Improve perception of fast loading by not rendering skeletons for individual blocks in the top part of the viewport
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/cache-do': patch
---
Enable Workers observability with a sampling of 0.1
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/icons': minor
---
Initial release for `@gitbook/icons`, a package of content icons to be used for pages, documents, etc.
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Automatically scroll to active item in TOC
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Add support for searching results in a sections site
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Persist state of tabs and dynamically sync them based on title
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Ensure "Sponsored via GitBook" can be translated in all languages
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Update ogimage with new design
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Show the caption for file blocks
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Use url hash to open Expandable and scroll to anchor
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Fix margin for paragraphs in quote blocks
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Use new cache backend, powered by Durable Objects, alongside the existing ones (KV, etc).
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Include offset in calculations of whether scrollable element is in view
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-openapi': minor
---
Add required query parameters to the code sample
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-openapi': minor
---
Display pattern if available in parmas in OpenAPI block
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Fix inconsistent click area in table because of scroll indicator
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Stop using KV cache backend for now, but also improves it for higher performances
-6
View File
@@ -1,6 +0,0 @@
---
'@gitbook/react-openapi': minor
'gitbook': patch
---
Synchronize response and response example tabs
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Show definition title when visible in cards
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Fix flickering when displaying an "Ask" answer with code blocks
-6
View File
@@ -1,6 +0,0 @@
---
'@gitbook/react-openapi': minor
'gitbook': patch
---
Rollback of scalar modal while fixing perf issue
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Optimize images rendered in community ads
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Update design of Checkbox to be more consistent and readable
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-contentkit': patch
---
Fix rendering of webframe with SSR causing wrong communication between frame and renderer
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Disable KV cache for docs.gitbook.com as a test, also disable it for change-request to improve consistency
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Add optional env `GITBOOK_INTEGRATIONS_HOST` to configure the host serving the integrations
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-openapi': patch
---
Fix crash when `example` is undefined for a response
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Improve the toolbar for change-requests and revisions to show more actions
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Added support for new Reusable Content block.
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Add support for icons style customization for sites
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-openapi': patch
---
Adds tabs to Response Example section e.g. for status code examples
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-openapi': patch
---
Render mandatory headers in code sample
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-openapi': patch
---
Update Scalar client to latest version
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Prevent search indexation for pages where it's configured as disabled
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Fix table of contents being visible on mobile when disabled at the page level
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Fix accessibility of the table of contents by using `aria-current` instead of `aria-selected`
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Update rendering of community ads to match new API response, and make it possible to preview ads.
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/react-math': minor
---
Export binary `gitbook-math` to copy assets to a directory
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Fix "ip" being passed to BSA for community ads
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Improving the look and feel of new section tabs
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Changed the alternative URL resolution criteria in order to support site URLs without /v/ prefix
-5
View File
@@ -1,5 +0,0 @@
---
'@gitbook/icons': minor
---
Fix bin gitbook-icons when installed without the Pro token
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': patch
---
Don't show hidden pages in the empty state of a page
-5
View File
@@ -1,5 +0,0 @@
---
'gitbook': minor
---
Fix linking to a tab itself
-9
View File
@@ -1,9 +0,0 @@
---
'gitbook': patch
---
Update header styling of sections, variant selector, and button links
- Change position of variant selector depending on context (next to logo or in table of contents)
- Update section tab styling and animation
- Make header buttons smaller with a new `medium` button size
+43 -11
View File
@@ -13,8 +13,12 @@ jobs:
permissions:
contents: read
deployments: write
issues: write
pull-requests: write
checks: write
statuses: write
outputs:
deployment_url: ${{ steps.cloudflare.outputs.url }}
deployment_url: ${{ steps.deploy.outputs.url }}
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -52,27 +56,55 @@ jobs:
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
SENTRY_DSN: ${{ vars.SENTRY_DSN }}
- id: cloudflare
name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
- id: deploy
name: Deploy to Cloudflare
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
directory: ./packages/gitbook/.vercel/output/static
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
workingDirectory: ./
wranglerVersion: '3.82.0'
command: pages deploy ./packages/gitbook/.vercel/output/static --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch=${{ github.ref == 'refs/heads/main' && 'main' || format('pr{0}', github.event.pull_request.number) }}
- name: Outputs
run: |
echo "ID: ${{ steps.cloudflare.outputs.id }}"
echo "URL: ${{ steps.cloudflare.outputs.url }}"
echo "Environment: ${{ steps.cloudflare.outputs.environment }}"
echo "Alias: ${{ steps.cloudflare.outputs.alias }}"
echo "URL: ${{ steps.deploy.outputs.url }}"
echo "Alias URL: ${{ steps.deploy.outputs.deployment-alias-url }}"
- name: Archive build output
uses: actions/upload-artifact@v4
with:
name: build-output
path: .vercel/
# Until https://github.com/cloudflare/wrangler-action/issues/301 is done
- name: Update Deployment Status to Success
env:
DEPLOYMENT_URL: ${{ steps.deploy.outputs.url }}
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"state": "success", "target_url": "${{ steps.deploy.outputs.url }}", "description": "Deployed Preview URL for commit", "context": "cloudflare/preview"}' \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
- name: Find GitHub Comment
uses: peter-evans/find-comment@v3
id: fc
if: 1 && !startsWith(github.ref, 'refs/heads/main')
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: GitBook Preview
- name: Create or update GitHub comment
uses: peter-evans/create-or-update-comment@v4
if: 1 && !startsWith(github.ref, 'refs/heads/main')
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
**GitBook Preview**
Latest commit: [${{ steps.deploy.outputs.url }}](${{ steps.deploy.outputs.url }})
PR: [${{ steps.deploy.outputs.alias }}](${{ steps.deploy.outputs.alias }})
edit-mode: replace
visual-testing:
runs-on: ubuntu-latest
name: Visual Testing
BIN
View File
Binary file not shown.
+12
View File
@@ -0,0 +1,12 @@
# @gitbook/cache-do
## 0.1.0
### Minor Changes
- 9b8d519: Experiment with optimizing billable duration in Cloudflare by using multiple RPC sessions instead of one
- 636b868: First version of a new cache backend powered by Cloudflare Durable Objects
### Patch Changes
- 56f5fa1: Enable Workers observability with a sampling of 0.1
+2 -2
View File
@@ -14,14 +14,14 @@
"default": "./dist/api.js"
}
},
"version": "0.0.0",
"version": "0.1.0",
"dependencies": {
"@msgpack/msgpack": "^3.0.0-beta2",
"lru_map": "^0.4.1"
},
"devDependencies": {
"typescript": "^5.5.3",
"wrangler": "^3.78.7"
"wrangler": "3.82.0"
},
"scripts": {
"generate": "wrangler types --experimental-include-runtime",
+95
View File
@@ -1,5 +1,100 @@
# gitbook
## 0.4.0
### Minor Changes
- e09f747: Revalidate change request cached content when pressing refresh button
- 2fa0851: Add navigation tabs for sections
- a4b63b8: Support resolution of new site URLs with sections
- 5c35f36: Replace all icons, previously imported from Geist, by new package `@gitbook/icons`
- e9b31a5: Unify section tab styles with page item styles
- f12a215: Add support for Norwegian language
- f4c9536: Optimize layout shift while transitioning between pages with full width blocks (ex: OpenAPI blocks)
- 1f24fe4: Add support for page icons
- cda08a9: Add support for searching results in a sections site
- b32e40c: Persist state of tabs and dynamically sync them based on title
- 15d2ee3: Show the caption for file blocks
- f885e88: Improve the toolbar for change-requests and revisions to show more actions
- 07ea45b: Remove deprecated synced block from GitBook Open
- c3675fd: Added support for new Reusable Content block.
- 1f24fe4: Add support for icons style customization for sites
- 4c19014: Prevent search indexation for pages where it's configured as disabled
- 3422ad4: Update rendering of community ads to match new API response, and make it possible to preview ads.
- 1152445: Changed the alternative URL resolution criteria in order to support site URLs without /v/ prefix
- 2c437f7: Fix linking to a tab itself
### Patch Changes
- aa32198: Avoid multiple <h1> in the page by using a <div> for the title in the header
- 51fa3ab: Adds content-visibility css property to OpenAPI Operation for better render performance
- a7066cc: Fix scroll position when navigating pages on mobile
- c754fc9: Add automatic color contrast in site header, restyle search button
- 5fe7adb: RND-3532: drop down menu for hidden links at small screen size
- 6295881: Change dark mode shadow for multi-space search toolbar
- f89b31c: Upgrade the scalar api client package
- 13c7534: Use ellipsis and fix icon color for more links in the header on small screen
- f885e88: Improve consistency of change request preview by removing cache-control on response
- 16e6171: Improve performances of loading pages with embeds by caching them
- 34d36c6: Fix GitBook specific static assets not being served correctly when deployed on Cloudflare
- af9e66e: Only display spaces dropdown in compact header when site is multi-variants
- e3a3d6a: Improve perception of fast loading by not rendering skeletons for individual blocks in the top part of the viewport
- 042b850: Automatically scroll to active item in TOC
- d43202f: Optimize bundle size of the server output by reducing bundle size of shiki (skipping themes)
- bfbed1a: Ensure "Sponsored via GitBook" can be translated in all languages
- fe9e6c1: Update ogimage with new design
- 17f71ba: Use url hash to open Expandable and scroll to anchor
- 3c07e65: Fix margin for paragraphs in quote blocks
- 636b868: Use new cache backend, powered by Durable Objects, alongside the existing ones (KV, etc).
- f16560c: Include offset in calculations of whether scrollable element is in view
- 689f553: Fix inconsistent click area in table because of scroll indicator
- 6ce3cea: Stop using KV cache backend for now, but also improves it for higher performances
- e914903: Synchronize response and response example tabs
- 0f990c7: Show definition title when visible in cards
- e3a3d6a: Fix flickering when displaying an "Ask" answer with code blocks
- 4cbcc5b: Rollback of scalar modal while fixing perf issue
- 3996110: Optimize images rendered in community ads
- 133c3e7: Update design of Checkbox to be more consistent and readable
- 5096f7f: Disable KV cache for docs.gitbook.com as a test, also disable it for change-request to improve consistency
- 0f1565c: Add optional env `GITBOOK_INTEGRATIONS_HOST` to configure the host serving the integrations
- 2ff7ed1: Fix table of contents being visible on mobile when disabled at the page level
- b075f0f: Fix accessibility of the table of contents by using `aria-current` instead of `aria-selected`
- cb782a7: Fix "ip" being passed to BSA for community ads
- a7af3ca: Improving the look and feel of new section tabs
- 0bf985a: Don't show hidden pages in the empty state of a page
- d6c28a0: Update header styling of sections, variant selector, and button links
- Change position of variant selector depending on context (next to logo or in table of contents)
- Update section tab styling and animation
- Make header buttons smaller with a new `medium` button size
- Updated dependencies [51fa3ab]
- Updated dependencies [9b8d519]
- Updated dependencies [cf3045a]
- Updated dependencies [f89b31c]
- Updated dependencies [d0f4860]
- Updated dependencies [ef9d012]
- Updated dependencies [094e9cd]
- Updated dependencies [636b868]
- Updated dependencies [56f5fa1]
- Updated dependencies [5c35f36]
- Updated dependencies [4247361]
- Updated dependencies [aa8c49e]
- Updated dependencies [e914903]
- Updated dependencies [4cbcc5b]
- Updated dependencies [0f1565c]
- Updated dependencies [237b703]
- Updated dependencies [51955da]
- Updated dependencies [a679e72]
- Updated dependencies [c079c3c]
- Updated dependencies [5c35f36]
- Updated dependencies [776bc31]
- @gitbook/react-openapi@0.7.0
- @gitbook/cache-do@0.1.0
- @gitbook/icons@0.1.0
- @gitbook/react-contentkit@0.5.1
- @gitbook/react-math@0.6.0
## 0.3.0
### Minor Changes
-2
View File
@@ -466,13 +466,11 @@ const testCases: TestsCase[] = [
{
title: 'Secondary button',
to: { kind: 'url', url: 'https://www.gitbook.com' },
// @ts-ignore Remove once we upgrade to the latest version of the API
style: 'button-secondary',
},
{
title: 'Primary button',
to: { kind: 'url', url: 'https://www.gitbook.com' },
// @ts-ignore Remove once we upgrade to the latest version of the API
style: 'button-primary',
},
],
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook",
"version": "0.3.0",
"version": "0.4.0",
"private": true,
"scripts": {
"dev": "env-cmd --silent -f ../../.env.local next dev",
@@ -16,7 +16,7 @@
"clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static"
},
"dependencies": {
"@gitbook/api": "^0.72.0",
"@gitbook/api": "^0.73.0",
"@gitbook/cache-do": "workspace:*",
"@gitbook/emoji-codepoints": "workspace:*",
"@gitbook/icons": "workspace:*",
@@ -60,7 +60,7 @@
"remark-rehype": "^11.1.0",
"rison": "^0.1.1",
"server-only": "^0.0.1",
"shiki": "^1.11.1",
"shiki": "^1.22.0",
"tailwind-merge": "^2.2.0",
"tailwind-shades": "^1.1.2",
"unified": "^11.0.4",
@@ -69,7 +69,7 @@
"devDependencies": {
"@argos-ci/playwright": "^2.0.0",
"@playwright/test": "^1.42.1",
"@cloudflare/next-on-pages": "^1.13.3",
"@cloudflare/next-on-pages": "^1.13.5",
"@cloudflare/workers-types": "^4.20240725.0",
"@types/js-cookie": "^3.0.6",
"@types/jsontoxml": "^1.0.5",
@@ -11,7 +11,6 @@ import {
import { ClassValue } from '@/lib/tailwind';
import { BlockContentRef } from './BlockContentRef';
import { BlockSyncedBlock } from './BlockSyncedBlock';
import { CodeBlock } from './CodeBlock';
import { Divider } from './Divider';
import { DocumentContextProps } from './DocumentView';
@@ -107,8 +106,6 @@ export function Block<T extends DocumentBlock>(props: BlockProps<T>) {
throw new Error('Blocks should be directly rendered by parent');
case 'integration':
return <IntegrationBlock {...props} block={block} />;
case 'synced-block':
return <BlockSyncedBlock {...props} block={block} />;
case 'reusable-content':
return <ReusableContent {...props} block={block} />;
case 'stepper':
@@ -165,7 +162,6 @@ export function BlockSkeleton(props: { block: DocumentBlock; style: ClassValue }
case 'content-ref':
case 'integration':
case 'stepper':
case 'synced-block':
case 'reusable-content':
return <SkeletonCard id={id} style={style} />;
case 'embed':
@@ -1,52 +0,0 @@
import { DocumentBlockSyncedBlock } from '@gitbook/api';
import { getSyncedBlockContent } from '@/lib/api';
import { resolveContentRefWithFiles } from '@/lib/references';
import { BlockProps } from './Block';
import { Blocks, UnwrappedBlocks } from './Blocks';
export async function BlockSyncedBlock(props: BlockProps<DocumentBlockSyncedBlock>) {
const { block, ancestorBlocks, context, style } = props;
const apiToken = block.meta?.apiToken;
if (!apiToken) {
return null;
}
// We can't resolve the synced block without an organization context.
if (!context.contentRefContext) {
return null;
}
const syncedBlock = await getSyncedBlockContent(
apiToken,
context.contentRefContext.space.organization,
block.data.ref.syncedBlock,
);
if (!syncedBlock) {
return null;
}
return (
<UnwrappedBlocks
nodes={syncedBlock.document.nodes}
document={syncedBlock.document}
ancestorBlocks={[...ancestorBlocks, block]}
context={{
...context,
resolveContentRef: async (ref, options) => {
if (!syncedBlock?.files) {
return context.resolveContentRef(ref, options);
}
const result = resolveContentRefWithFiles(syncedBlock.files, ref);
if (result !== undefined) {
return result;
}
return context.resolveContentRef(ref, options);
},
}}
/>
);
}
@@ -1,13 +1,12 @@
import { DocumentBlockCode, DocumentBlockCodeLine, DocumentInlineAnnotation } from '@gitbook/api';
import {
loadWasm,
createdBundledHighlighter,
ThemedToken,
getHighlighter,
createCssVariablesTheme,
HighlighterGeneric,
bundledLanguages,
bundledThemes,
} from 'shiki';
} from 'shiki/core';
import { loadWasm, createOnigurumaEngine } from 'shiki/engine/oniguruma';
import { bundledLanguages } from 'shiki/langs';
// @ts-ignore - onigWasm is a Wasm module
import onigWasm from 'shiki/onig.wasm?module';
@@ -15,8 +14,6 @@ import { asyncMutexFunction, singleton } from '@/lib/async';
import { getNodeText } from '@/lib/document';
import { trace } from '@/lib/tracing';
import { DocumentContext } from '../DocumentView';
export type HighlightLine = {
highlighted: boolean;
tokens: HighlightToken[];
@@ -299,6 +296,12 @@ function cleanupLine(line: string): string {
return line.replace(/\r/g, '');
}
const createHighlighter = createdBundledHighlighter<any, any>({
langs: bundledLanguages,
themes: {},
engine: () => createOnigurumaEngine(import('shiki/wasm')),
});
/**
* Load the highlighter, only once, and reuse it.
* It makes sure to handle concurrent calls.
@@ -312,7 +315,8 @@ const loadHighlighter = singleton(async () => {
// Otherwise for Vercel/Cloudflare, we need to load it ourselves.
await loadWasm((obj) => WebAssembly.instantiate(onigWasm, obj));
}
const highlighter = await getHighlighter({
const highlighter = await createHighlighter({
themes: [createCssVariablesTheme()],
langs: [],
});
@@ -322,7 +326,7 @@ const loadHighlighter = singleton(async () => {
const loadLanguagesMutex = asyncMutexFunction();
async function loadHighlighterLanguage(
highlighter: HighlighterGeneric<keyof typeof bundledLanguages, keyof typeof bundledThemes>,
highlighter: HighlighterGeneric<any, any>,
lang: keyof typeof bundledLanguages,
) {
await loadLanguagesMutex.runBlocking(async () => {
@@ -29,7 +29,7 @@ export async function OpenAPI(props: BlockProps<DocumentBlockSwagger>) {
async function OpenAPIBody(props: BlockProps<DocumentBlockSwagger>) {
const { block, context } = props;
const { data, error } = await fetchOpenAPIBlock(block, context.resolveContentRef);
const { data, specUrl, error } = await fetchOpenAPIBlock(block, context.resolveContentRef);
if (error) {
return (
@@ -41,7 +41,7 @@ async function OpenAPIBody(props: BlockProps<DocumentBlockSwagger>) {
);
}
if (!data) {
if (!data || !specUrl) {
return null;
}
@@ -49,6 +49,7 @@ async function OpenAPIBody(props: BlockProps<DocumentBlockSwagger>) {
<OpenAPIOperation
data={data}
context={{
specUrl,
icons: {
chevronDown: <Icon icon="chevron-down" />,
chevronRight: <Icon icon="chevron-right" />,
@@ -1,4 +1,7 @@
@import '@scalar/api-client-react/style.css';
.light .scalar-modal-layout,
.light .scalar-app,
.light .scalar {
--scalar-color-1: color-mix(
in srgb,
@@ -50,8 +53,13 @@
--scalar-button-1: rgb(49 53 56);
--scalar-button-1-color: #fff;
--scalar-button-1-hover: rgb(28 31 33);
--scalar-shadow-1: 0 1px 3px 0 rgba(0, 0, 0, 0.11);
--scalar-shadow-2: rgba(0, 0, 0, 0.08) 0px 13px 20px 0px, rgba(0, 0, 0, 0.08) 0px 3px 8px 0px,
#eeeeed 0px 0 0 1px;
}
.dark .scalar-modal-layout,
.dark .scalar-app,
.dark .scalar {
--scalar-color-1: color-mix(
in srgb,
@@ -102,8 +110,13 @@
--scalar-button-1: #f6f6f6;
--scalar-button-1-color: #000;
--scalar-button-1-hover: #e7e7e7;
--scalar-shadow-1: 0 1px 3px 0 rgb(0, 0, 0, 0.1);
--scalar-shadow-2: rgba(15, 15, 15, 0.2) 0px 3px 6px, rgba(15, 15, 15, 0.4) 0px 9px 24px,
0 0 0 1px rgba(255, 255, 255, 0.1);
}
.scalar-modal-layout,
.scalar-app,
.scalar {
--scalar-font: initial;
--scalar-font-code: var(--font-mono);
@@ -165,7 +178,7 @@
.scalar-api-client__close:hover {
cursor: pointer;
}
.scalar .scalar-app {
.scalar .scalar-app-layout {
background: var(--scalar-background-3);
height: calc(100dvh - 100px);
max-width: 1280px;
@@ -202,23 +215,6 @@
cursor: pointer;
animation: scalardrawerexitfadein 0.35s forwards;
}
.scalar .scalar-app-exit:before {
content: '\00d7';
font-family: sans-serif;
position: absolute;
top: 0;
right: 0;
font-size: 30px;
font-weight: 100;
line-height: 50px;
right: 12px;
text-align: center;
color: white;
opacity: 0.6;
}
.scalar .scalar-app-exit:hover:before {
opacity: 1;
}
@keyframes scalardrawerexitfadein {
from {
opacity: 0;
@@ -305,11 +301,6 @@
scrollbar-width: thin;
-webkit-overflow-scrolling: touch;
}
@supports (-moz-appearance: none) {
.scalar .custom-scroll {
padding-right: 12px;
}
}
.scalar .custom-scroll:hover {
scrollbar-color: rgba(0, 0, 0, 0.24) transparent;
}
@@ -347,3 +338,18 @@
padding-right: 12px;
}
}
.dark .scalar .client-wrapper-bg-color {
background: linear-gradient(
color-mix(in srgb, var(--tw-bg-base) 6%, transparent) 1%,
color-mix(in srgb, var(--scalar-background-1) 30%, black) 9%
);
}
.light .scalar .client-wrapper-bg-color {
background-color: var(--scalar-background-2) !important;
}
.scalar .gitbook-show {
display: block !important;
}
.scalar .gitbook-hidden {
display: none !important;
}
@@ -66,8 +66,10 @@ export async function HeaderLink(props: {
)
: null,
'button-secondary': tcls(
'bg:transparent hover:bg-transparent',
'dark:bg-transparent dark:hover:bg-transparent',
'ring-header-link-500 hover:ring-header-link-300 dark:ring-header-link-500 dark:hover:ring-header-link-300 text-header-link-500 dark:text-header-link-500',
'ring-header-link-500 hover:ring-header-link-300 text-header-link-500',
'dark:ring-header-link-500 dark:hover:ring-header-link-300 dark:text-header-link-500',
),
}[linkStyle],
)}
@@ -130,11 +130,7 @@ export function PageAside(props: {
>
{withPageFeedback ? (
<React.Suspense fallback={null}>
<PageFeedbackForm
spaceId={space.id}
pageId={page.id}
className={tcls('mt-2')}
/>
<PageFeedbackForm pageId={page.id} className={tcls('mt-2')} />
</React.Suspense>
) : null}
{customization.git.showEditLink && space.gitSync?.url && page.git ? (
@@ -141,11 +141,7 @@ export function PageBody(props: {
</p>
) : null}
{withPageFeedback ? (
<PageFeedbackForm
orientation="horizontal"
spaceId={space.id}
pageId={page.id}
/>
<PageFeedbackForm orientation="horizontal" pageId={page.id} />
) : null}
</div>
</main>
@@ -15,18 +15,17 @@ import { postPageFeedback } from './server-actions';
*/
export function PageFeedbackForm(props: {
orientation?: 'horizontal' | 'vertical';
spaceId: string;
pageId: string;
className?: string;
}) {
const { orientation = 'vertical', spaceId, pageId, className } = props;
const { orientation = 'vertical', pageId, className } = props;
const languages = useLanguage();
const [submitted, setSubmitted] = React.useState(false);
const onSubmit = async (rating: PageFeedbackRating) => {
setSubmitted(true);
const visitorId = await getVisitorId();
await postPageFeedback({ spaceId, pageId, visitorId, rating });
await postPageFeedback({ pageId, visitorId, rating });
};
return (
@@ -1,16 +1,31 @@
'use server';
import { PageFeedbackRating } from '@gitbook/api';
import { assert } from 'ts-essentials';
import { api } from '@/lib/api';
import { getSiteContentPointer } from '@/lib/pointer';
export async function postPageFeedback(args: {
spaceId: string;
pageId: string;
visitorId: string;
rating: PageFeedbackRating;
}) {
await api().spaces.createPageFeedback(args.spaceId, args.pageId, args.visitorId, {
rating: args.rating,
});
const { organizationId, siteId, siteSpaceId } = getSiteContentPointer();
assert(
siteSpaceId,
`No siteSpaceId in pointer. organizationId: ${organizationId}, siteId: ${siteId}, pageId: ${args.pageId}`,
);
await api().orgs.createSitesPageFeedback(
organizationId,
siteId,
siteSpaceId,
args.pageId,
args.visitorId,
{
rating: args.rating,
},
);
}
@@ -119,7 +119,8 @@ const Tab = React.forwardRef<
className={tcls(
'px-3 py-1 my-2 rounded straight-corners:rounded-none transition-colors',
active && 'text-primary dark:text-primary-400',
!active && ' hover:bg-light-2 dark:hover:bg-dark-3',
!active &&
'text-dark/8 hover:bg-dark/1 hover:text-dark/9 dark:text-light/8 dark:hover:bg-light/2 dark:hover:text-light/9',
)}
role="tab"
href={href}
-49
View File
@@ -192,48 +192,6 @@ export const getUserById = cache({
},
});
/**
* Get a synced block by its ref.
*/
export const getSyncedBlockContent = cache({
name: 'api.getSyncedBlockContent',
tag: (apiToken, organizationId, syncedBlockId) =>
getAPICacheTag({
tag: 'synced-block',
syncedBlock: syncedBlockId,
}),
get: async (
apiToken: string,
organizationId: string,
syncedBlockId: string,
options: CacheFunctionOptions,
) => {
try {
const response = await apiWithToken(apiToken).orgs.getSyncedBlockContent(
organizationId,
syncedBlockId,
{
...noCacheFetchOptions,
signal: options.signal,
},
);
return cacheResponse(response, {
revalidateBefore: 60 * 60,
});
} catch (error) {
if ((error as GitBookAPIError).code === 404) {
return {
revalidateBefore: 60 * 60,
data: null,
};
}
throw error;
}
},
// We don't cache apiToken as it's not a stable key
getKeyArgs: (args) => [args[1], args[2]],
});
/**
* Resolve a URL to the content to render.
*/
@@ -1208,11 +1166,6 @@ export function getAPICacheTag(
tag: 'collection';
collection: string;
}
// All data related to a synced block
| {
tag: 'synced-block';
syncedBlock: string;
}
// All data related to a site
| {
tag: 'site';
@@ -1234,8 +1187,6 @@ export function getAPICacheTag(
return `space:${spec.space}:document:${spec.document}`;
case 'collection':
return `collection:${spec.collection}`;
case 'synced-block':
return `synced-block:${spec.syncedBlock}`;
case 'site':
return `site:${spec.site}`;
case 'integration':
+4 -4
View File
@@ -19,12 +19,12 @@ export async function fetchOpenAPIBlock(
block: DocumentBlockSwagger,
resolveContentRef: (ref: ContentRef) => Promise<ResolvedContentRef | null>,
): Promise<
| { data: OpenAPIOperationData | null; error?: undefined }
| { error: OpenAPIFetchError; data?: undefined }
| { data: OpenAPIOperationData | null; specUrl: string | null; error?: undefined }
| { error: OpenAPIFetchError; data?: undefined; specUrl?: undefined }
> {
const resolved = block.data.ref ? await resolveContentRef(block.data.ref) : null;
if (!resolved || !block.data.path || !block.data.method) {
return { data: null };
return { data: null, specUrl: null };
}
try {
@@ -37,7 +37,7 @@ export async function fetchOpenAPIBlock(
fetcher,
);
return { data };
return { data, specUrl: resolved.href };
} catch (error) {
if (error instanceof OpenAPIFetchError) {
return { error };
-21
View File
@@ -281,8 +281,6 @@ export async function resolveContentRef(
reusableContent,
};
}
case 'synced-block':
return null;
default:
assertNever(contentRef);
@@ -328,22 +326,3 @@ async function resolveContentRefInSpace(
subText: space.title,
};
}
export function resolveContentRefWithFiles(
files: RevisionFile[],
contentRef: ContentRef,
): ResolvedContentRef | null | undefined {
if (contentRef.kind === 'file') {
const file = files.find((file) => file.id === contentRef.file);
if (file) {
return {
href: file.downloadURL,
text: file.name,
active: false,
file,
};
}
return null;
}
return undefined;
}
+13
View File
@@ -0,0 +1,13 @@
# @gitbook/icons
## 0.1.0
### Minor Changes
- 5c35f36: Initial release for `@gitbook/icons`, a package of content icons to be used for pages, documents, etc.
- 776bc31: Fix bin gitbook-icons when installed without the Pro token
### Patch Changes
- d0f4860: Update version for static assets to fix invalid caching
- ef9d012: Fix first run of the package in development mode
+1 -1
View File
@@ -16,7 +16,7 @@
"default": "./src/style.css"
}
},
"version": "0.0.3",
"version": "0.1.0",
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.6.0",
"@fortawesome/fontawesome-free": "^6.6.0"
+6
View File
@@ -1,5 +1,11 @@
# @gitbook/react-contentkit
## 0.5.1
### Patch Changes
- 0f1565c: Fix rendering of webframe with SSR causing wrong communication between frame and renderer
## 0.5.0
### Minor Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@gitbook/react-contentkit",
"version": "0.5.0",
"version": "0.5.1",
"exports": {
".": {
"types": "./dist/index.d.ts",
+6
View File
@@ -1,5 +1,11 @@
# @gitbook/react-math
## 0.6.0
### Minor Changes
- 5c35f36: Export binary `gitbook-math` to copy assets to a directory
## 0.5.0
### Minor Changes
+1 -1
View File
@@ -8,7 +8,7 @@
"default": "./dist/index.js"
}
},
"version": "0.5.0",
"version": "0.6.0",
"dependencies": {
"object-hash": "^3.0.0"
},
+20
View File
@@ -1,5 +1,25 @@
# @gitbook/react-openapi
## 0.7.0
### Minor Changes
- cf3045a: Add Python support in Code Samples
- 4247361: Add required query parameters to the code sample
- aa8c49e: Display pattern if available in parmas in OpenAPI block
- e914903: Synchronize response and response example tabs
- 4cbcc5b: Rollback of scalar modal while fixing perf issue
### Patch Changes
- 51fa3ab: Adds content-visibility css property to OpenAPI Operation for better render performance
- f89b31c: Upgrade the scalar api client package
- 094e9cd: bump: scalar from 1.0.5 to 1.0.7
- 237b703: Fix crash when `example` is undefined for a response
- 51955da: Adds tabs to Response Example section e.g. for status code examples
- a679e72: Render mandatory headers in code sample
- c079c3c: Update Scalar client to latest version
## 0.6.0
### Minor Changes
+2 -3
View File
@@ -8,10 +8,9 @@
"default": "./dist/index.js"
}
},
"version": "0.6.0",
"version": "0.7.0",
"dependencies": {
"@scalar/api-client-react": "0.3.7",
"@scalar/oas-utils": "0.1.6",
"@scalar/api-client-react": "1.0.65",
"classnames": "^2.5.1",
"flatted": "^3.2.9",
"openapi-types": "^12.1.3",
@@ -1,7 +1,7 @@
import * as React from 'react';
import { CodeSampleInput, codeSampleGenerators } from './code-samples';
import { OpenAPIOperationData, toJSON } from './fetchOpenAPIOperation';
import { OpenAPIOperationData } from './fetchOpenAPIOperation';
import { generateMediaTypeExample, generateSchemaExample } from './generateSchemaExample';
import { InteractiveSection } from './InteractiveSection';
import { getServersURL } from './OpenAPIServerURL';
@@ -112,11 +112,6 @@ export function OpenAPICodeSample(props: {
return null;
}
async function fetchOperationData() {
'use server';
return toJSON(data);
}
return (
<InteractiveSection
header="Request"
@@ -124,7 +119,7 @@ export function OpenAPICodeSample(props: {
tabs={samples}
overlay={
data['x-hideTryItPanel'] || data.operation['x-hideTryItPanel'] ? null : (
<ScalarApiButton fetchOperationData={fetchOperationData} />
<ScalarApiButton />
)
}
/>
@@ -1,5 +1,6 @@
import * as React from 'react';
import classNames from 'classnames';
import { ApiClientModalProvider } from '@scalar/api-client-react';
import { OpenAPIOperationData, toJSON } from './fetchOpenAPIOperation';
import { Markdown } from './Markdown';
@@ -8,7 +9,6 @@ import { OpenAPIResponseExample } from './OpenAPIResponseExample';
import { OpenAPIServerURL } from './OpenAPIServerURL';
import { OpenAPISpec } from './OpenAPISpec';
import { OpenAPIClientContext, OpenAPIContextProps } from './types';
import { ScalarApiClient } from './ScalarApiButton';
/**
* Display an interactive OpenAPI operation.
@@ -28,7 +28,10 @@ export function OpenAPIOperation(props: {
};
return (
<ScalarApiClient>
<ApiClientModalProvider
configuration={{ spec: { url: context.specUrl } }}
initialRequest={{ path: data.path, method: data.method }}
>
<div className={classNames('openapi-operation', className)}>
<div className="openapi-intro">
<h2 className="openapi-summary" id={context.id}>
@@ -64,6 +67,6 @@ export function OpenAPIOperation(props: {
</div>
</div>
</div>
</ScalarApiClient>
</ApiClientModalProvider>
);
}

Some files were not shown because too many files have changed in this diff Show More