mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-02 18:23:49 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52a61fd1e3 | |||
| 5abe43b451 | |||
| e82744d952 | |||
| 68bfc636b2 | |||
| c008cc7cc2 | |||
| a41fb53445 | |||
| 8f4085d392 | |||
| a4f81c28b0 |
@@ -1 +0,0 @@
|
|||||||
1.2.1
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Avoid multiple <h1> in the page by using a <div> for the title in the header
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Adds content-visibility css property to OpenAPI Operation for better render performance
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/cache-do': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Experiment with optimizing billable duration in Cloudflare by using multiple RPC sessions instead of one
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix scroll position when navigating pages on mobile
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add Python support in Code Samples
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add automatic color contrast in site header, restyle search button
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
RND-3532: drop down menu for hidden links at small screen size
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Change dark mode shadow for multi-space search toolbar
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Use ellipsis and fix icon color for more links in the header on small screen
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve consistency of change request preview by removing cache-control on response
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/icons': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Update version for static assets to fix invalid caching
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Revalidate change request cached content when pressing refresh button
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/icons': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix first run of the package in development mode
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add navigation tabs for sections
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve performances of loading pages with embeds by caching them
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
bump: scalar from 1.0.5 to 1.0.7
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Support resolution of new site URLs with sections
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Replace all icons, previously imported from Geist, by new package `@gitbook/icons`
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/cache-do': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
First version of a new cache backend powered by Cloudflare Durable Objects
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for Norwegian language
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Optimize layout shift while transitioning between pages with full width blocks (ex: OpenAPI blocks)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for page icons
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix GitBook specific static assets not being served correctly when deployed on Cloudflare
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Only display spaces dropdown in compact header when site is multi-variants
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve perception of fast loading by not rendering skeletons for individual blocks in the top part of the viewport
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/cache-do': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Enable Workers observability with a sampling of 0.1
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/icons': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Initial release for `@gitbook/icons`, a package of content icons to be used for pages, documents, etc.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Automatically scroll to active item in TOC
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for searching results in a sections site
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Persist state of tabs and dynamically sync them based on title
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Ensure "Sponsored via GitBook" can be translated in all languages
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Update ogimage with new design
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Show the caption for file blocks
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Use url hash to open Expandable and scroll to anchor
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix margin for paragraphs in quote blocks
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Use new cache backend, powered by Durable Objects, alongside the existing ones (KV, etc).
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Include offset in calculations of whether scrollable element is in view
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add required query parameters to the code sample
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Display pattern if available in parmas in OpenAPI block
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix inconsistent click area in table because of scroll indicator
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Stop using KV cache backend for now, but also improves it for higher performances
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': minor
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Synchronize response and response example tabs
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Show definition title when visible in cards
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix flickering when displaying an "Ask" answer with code blocks
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': minor
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Rollback of scalar modal while fixing perf issue
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Optimize images rendered in community ads
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Update design of Checkbox to be more consistent and readable
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-contentkit': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix rendering of webframe with SSR causing wrong communication between frame and renderer
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Disable KV cache for docs.gitbook.com as a test, also disable it for change-request to improve consistency
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add optional env `GITBOOK_INTEGRATIONS_HOST` to configure the host serving the integrations
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix crash when `example` is undefined for a response
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve the toolbar for change-requests and revisions to show more actions
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Added support for new Reusable Content block.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for icons style customization for sites
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Adds tabs to Response Example section e.g. for status code examples
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Render mandatory headers in code sample
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Update Scalar client to latest version
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Prevent search indexation for pages where it's configured as disabled
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix table of contents being visible on mobile when disabled at the page level
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix accessibility of the table of contents by using `aria-current` instead of `aria-selected`
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Update rendering of community ads to match new API response, and make it possible to preview ads.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-math': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Export binary `gitbook-math` to copy assets to a directory
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix "ip" being passed to BSA for community ads
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improving the look and feel of new section tabs
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Changed the alternative URL resolution criteria in order to support site URLs without /v/ prefix
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/icons': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix bin gitbook-icons when installed without the Pro token
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Don't show hidden pages in the empty state of a page
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix linking to a tab itself
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
'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
|
||||||
@@ -12,7 +12,7 @@ runs:
|
|||||||
|
|
||||||
# Cache browser binaries, cache key is based on Playwright version and OS
|
# Cache browser binaries, cache key is based on Playwright version and OS
|
||||||
- name: 🧰 Cache Playwright browser binaries
|
- name: 🧰 Cache Playwright browser binaries
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v3
|
||||||
id: playwright-cache
|
id: playwright-cache
|
||||||
with:
|
with:
|
||||||
path: '~/.cache/ms-playwright'
|
path: '~/.cache/ms-playwright'
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
name: 'Setup Bun'
|
|
||||||
description: 'Install Bun and cache dependencies'
|
|
||||||
runs:
|
|
||||||
using: 'composite'
|
|
||||||
steps:
|
|
||||||
# We cache dependencies even if Bun is fast to avoid downloading fontawesome too many times
|
|
||||||
# and impacting bandwidth there.
|
|
||||||
- name: Cache bun
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.bun/install/cache
|
|
||||||
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**/bun.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-bun-
|
|
||||||
- name: Setup bun
|
|
||||||
uses: oven-sh/setup-bun@v2
|
|
||||||
with:
|
|
||||||
bun-version-file: '.bun-version'
|
|
||||||
+59
-226
@@ -5,7 +5,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
env:
|
env:
|
||||||
NPM_TOKEN_READONLY: ${{ secrets.NPM_TOKEN_READONLY }}
|
NPMRC_FONT_AWESOME_TOKEN: ${{ secrets.NPMRC_FONT_AWESOME_TOKEN }}
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to Cloudflare Pages
|
name: Deploy to Cloudflare Pages
|
||||||
@@ -13,22 +13,29 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
deployments: write
|
deployments: write
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
checks: write
|
|
||||||
statuses: write
|
|
||||||
outputs:
|
outputs:
|
||||||
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
|
deployment_url: ${{ steps.cloudflare.outputs.url }}
|
||||||
deployment-alias-url: ${{ steps.deploy.outputs.deployment-alias-url }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
PUPPETEER_SKIP_DOWNLOAD: 1
|
PUPPETEER_SKIP_DOWNLOAD: 1
|
||||||
|
- name: Cache Next.js build
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
${{ github.workspace }}/.next/cache
|
||||||
|
# Generate a new cache whenever packages or source files change.
|
||||||
|
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
|
||||||
|
# If source files changed but packages didn't, rebuild from a prior cache.
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-
|
||||||
- name: Sets env vars for production
|
- name: Sets env vars for production
|
||||||
run: |
|
run: |
|
||||||
echo "SENTRY_ENVIRONMENT=production" >> $GITHUB_ENV
|
echo "SENTRY_ENVIRONMENT=production" >> $GITHUB_ENV
|
||||||
@@ -39,196 +46,33 @@ jobs:
|
|||||||
echo "SENTRY_ENVIRONMENT=preview" >> $GITHUB_ENV
|
echo "SENTRY_ENVIRONMENT=preview" >> $GITHUB_ENV
|
||||||
if: 1 && !startsWith(github.ref, 'refs/heads/main')
|
if: 1 && !startsWith(github.ref, 'refs/heads/main')
|
||||||
- name: Build Next.js with next-on-pages
|
- name: Build Next.js with next-on-pages
|
||||||
run: bun run turbo build:cloudflare
|
run: bun run build:cloudflare
|
||||||
env:
|
env:
|
||||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||||
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: ${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
|
|
||||||
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
|
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
|
||||||
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
|
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
|
||||||
SENTRY_DSN: ${{ vars.SENTRY_DSN }}
|
SENTRY_DSN: ${{ vars.SENTRY_DSN }}
|
||||||
SENTRY_RELEASE: ${{ github.sha }}
|
- id: cloudflare
|
||||||
- id: deploy
|
name: Publish to Cloudflare Pages
|
||||||
name: Deploy to Cloudflare
|
uses: cloudflare/pages-action@v1
|
||||||
uses: cloudflare/wrangler-action@v3.11.0
|
|
||||||
with:
|
with:
|
||||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
|
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
|
||||||
|
directory: ./packages/gitbook/.vercel/output/static
|
||||||
|
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
workingDirectory: ./
|
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
|
- name: Outputs
|
||||||
run: |
|
run: |
|
||||||
echo "URL: ${{ steps.deploy.outputs.deployment-url }}"
|
echo "ID: ${{ steps.cloudflare.outputs.id }}"
|
||||||
echo "Alias URL: ${{ steps.deploy.outputs.deployment-alias-url }}"
|
echo "URL: ${{ steps.cloudflare.outputs.url }}"
|
||||||
|
echo "Environment: ${{ steps.cloudflare.outputs.environment }}"
|
||||||
|
echo "Alias: ${{ steps.cloudflare.outputs.alias }}"
|
||||||
- name: Archive build output
|
- name: Archive build output
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build-output
|
name: build-output
|
||||||
path: .vercel/
|
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.deployment-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.deployment-url }}", "description": "Deployed Preview URL for commit", "context": "cloudflare/preview"}' \
|
|
||||||
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
|
|
||||||
deploy-v2-vercel:
|
|
||||||
name: Deploy v2 to Vercel
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
deployments: write
|
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
checks: write
|
|
||||||
statuses: write
|
|
||||||
outputs:
|
|
||||||
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
|
|
||||||
env:
|
|
||||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
|
||||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Setup Bun
|
|
||||||
uses: ./.github/composite/setup-bun
|
|
||||||
- name: Install dependencies
|
|
||||||
run: bun install --frozen-lockfile
|
|
||||||
env:
|
|
||||||
PUPPETEER_SKIP_DOWNLOAD: 1
|
|
||||||
- name: Sets env vars for production
|
|
||||||
run: |
|
|
||||||
echo "VERCEL_ENVIRONMENT=production" >> $GITHUB_ENV
|
|
||||||
echo "SENTRY_ENVIRONMENT=production" >> $GITHUB_ENV
|
|
||||||
echo "GITBOOK_ASSETS_PREFIX=https://static.gitbook.com" >> $GITHUB_ENV
|
|
||||||
if: startsWith(github.ref, 'refs/heads/main')
|
|
||||||
- name: Sets env vars for preview
|
|
||||||
run: |
|
|
||||||
echo "VERCEL_ENVIRONMENT=preview" >> $GITHUB_ENV
|
|
||||||
echo "SENTRY_ENVIRONMENT=preview" >> $GITHUB_ENV
|
|
||||||
if: 1 && !startsWith(github.ref, 'refs/heads/main')
|
|
||||||
- name: Pull Vercel Environment Information
|
|
||||||
run: bun run vercel pull --yes --environment=$VERCEL_ENVIRONMENT --token=${{ secrets.VERCEL_TOKEN }}
|
|
||||||
- name: Build Project Artifacts
|
|
||||||
run: bun run vercel build --token=${{ secrets.VERCEL_TOKEN }}
|
|
||||||
env:
|
|
||||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
||||||
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: ${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
|
|
||||||
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
|
|
||||||
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
|
|
||||||
SENTRY_DSN: ${{ vars.SENTRY_DSN }}
|
|
||||||
SENTRY_RELEASE: ${{ github.sha }}
|
|
||||||
- name: Deploy Project Artifacts to Vercel
|
|
||||||
id: deploy
|
|
||||||
run: |
|
|
||||||
DEPLOYMENT_URL=$(bun run vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
|
|
||||||
echo "deployment-url=$DEPLOYMENT_URL" >> "$GITHUB_OUTPUT"
|
|
||||||
- name: Outputs
|
|
||||||
run: |
|
|
||||||
echo "URL: ${{ steps.deploy.outputs.deployment-url }}"
|
|
||||||
deploy-v2-cloudflare:
|
|
||||||
name: Deploy v2 to Cloudflare Worker
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
deployments: write
|
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
checks: write
|
|
||||||
statuses: write
|
|
||||||
outputs:
|
|
||||||
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
|
|
||||||
env:
|
|
||||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
|
||||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Setup Bun
|
|
||||||
uses: ./.github/composite/setup-bun
|
|
||||||
- name: Install dependencies
|
|
||||||
run: bun install --frozen-lockfile
|
|
||||||
env:
|
|
||||||
PUPPETEER_SKIP_DOWNLOAD: 1
|
|
||||||
- name: Sets env vars for production
|
|
||||||
run: |
|
|
||||||
echo "SENTRY_ENVIRONMENT=production" >> $GITHUB_ENV
|
|
||||||
echo "GITBOOK_ASSETS_PREFIX=https://static.gitbook.com" >> $GITHUB_ENV
|
|
||||||
if: startsWith(github.ref, 'refs/heads/main')
|
|
||||||
- name: Sets env vars for preview
|
|
||||||
run: |
|
|
||||||
echo "SENTRY_ENVIRONMENT=preview" >> $GITHUB_ENV
|
|
||||||
if: 1 && !startsWith(github.ref, 'refs/heads/main')
|
|
||||||
- name: Build worker
|
|
||||||
run: bun run turbo build:v2:cloudflare
|
|
||||||
env:
|
|
||||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
||||||
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: ${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
|
|
||||||
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
|
|
||||||
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
|
|
||||||
SENTRY_DSN: ${{ vars.SENTRY_DSN }}
|
|
||||||
SENTRY_RELEASE: ${{ github.sha }}
|
|
||||||
- id: deploy
|
|
||||||
name: Deploy to Cloudflare
|
|
||||||
uses: cloudflare/wrangler-action@v3.11.0
|
|
||||||
with:
|
|
||||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
||||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
||||||
workingDirectory: ./
|
|
||||||
wranglerVersion: '3.82.0'
|
|
||||||
command: versions upload --config ./packages/gitbook-v2/wrangler.toml
|
|
||||||
- name: Outputs
|
|
||||||
run: |
|
|
||||||
echo "URL: ${{ steps.deploy.outputs.deployment-url }}"
|
|
||||||
comment-deployments:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Comment Deployments
|
|
||||||
if: always() && !startsWith(github.ref, 'refs/heads/main')
|
|
||||||
needs:
|
|
||||||
- deploy
|
|
||||||
- deploy-v2-vercel
|
|
||||||
- deploy-v2-cloudflare
|
|
||||||
steps:
|
|
||||||
- name: Find GitHub Comment
|
|
||||||
uses: peter-evans/find-comment@v3
|
|
||||||
id: fc
|
|
||||||
with:
|
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
|
||||||
comment-author: 'github-actions[bot]'
|
|
||||||
body-includes: 'Summary of the deployments'
|
|
||||||
|
|
||||||
- name: Create or update GitHub comment
|
|
||||||
uses: peter-evans/create-or-update-comment@v4
|
|
||||||
with:
|
|
||||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
|
||||||
body: |
|
|
||||||
Summary of the deployments:
|
|
||||||
|
|
||||||
### Version 1 (production)
|
|
||||||
|
|
||||||
| Version | URL | Status |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| Latest commit | [${{ needs.deploy.outputs.deployment-url }}](${{ needs.deploy.outputs.deployment-url }}) | ${{ needs.deploy.result == 'success' && '✅' || '❌' }} |
|
|
||||||
| PR | [${{ needs.deploy.outputs.deployment-alias-url }}](${{ needs.deploy.outputs.deployment-alias-url }}) | ${{ needs.deploy.result == 'success' && '✅' || '❌' }} |
|
|
||||||
|
|
||||||
### Version 2 (experimental)
|
|
||||||
|
|
||||||
| Version | URL | Status |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| Vercel | [${{ needs.deploy-v2-vercel.outputs.deployment-url }}](${{ needs.deploy-v2-vercel.outputs.deployment-url }}) | ${{ needs.deploy-v2-vercel.result == 'success' && '✅' || '❌' }} |
|
|
||||||
| Cloudflare | [${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}](${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}) | ${{ needs.deploy-v2-cloudflare.result == 'success' && '✅' || '❌' }} |
|
|
||||||
|
|
||||||
### Test content
|
|
||||||
|
|
||||||
| Site | v1 | v2 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| GitBook | [${{ needs.deploy.outputs.deployment-url }}/docs.gitbook.com](${{ needs.deploy.outputs.deployment-url }}/docs.gitbook.com) | [${{ needs.deploy-v2-vercel.outputs.deployment-url }}/static/url/docs.gitbook.com](${{ needs.deploy-v2-vercel.outputs.deployment-url }}/static/url/docs.gitbook.com) |
|
|
||||||
| E2E | [${{ needs.deploy.outputs.deployment-url }}/gitbook.gitbook.io/test-gitbook-open](${{ needs.deploy.outputs.deployment-url }}/gitbook.gitbook.io/test-gitbook-open) | [${{ needs.deploy-v2-vercel.outputs.deployment-url }}/static/url/gitbook.gitbook.io/test-gitbook-open](${{ needs.deploy-v2-vercel.outputs.deployment-url }}/static/url/gitbook.gitbook.io/test-gitbook-open) |
|
|
||||||
edit-mode: replace
|
|
||||||
visual-testing:
|
visual-testing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Visual Testing
|
name: Visual Testing
|
||||||
@@ -236,8 +80,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
- name: Setup Playwright
|
- name: Setup Playwright
|
||||||
@@ -245,7 +91,7 @@ jobs:
|
|||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
run: bun e2e
|
run: bun e2e
|
||||||
env:
|
env:
|
||||||
BASE_URL: ${{needs.deploy.outputs.deployment-url}}
|
BASE_URL: ${{needs.deploy.outputs.deployment_url}}
|
||||||
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
|
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
if: ${{ !cancelled() }}
|
if: ${{ !cancelled() }}
|
||||||
@@ -253,31 +99,6 @@ jobs:
|
|||||||
name: playwright-test-results
|
name: playwright-test-results
|
||||||
path: packages/gitbook/test-results/
|
path: packages/gitbook/test-results/
|
||||||
retention-days: 3
|
retention-days: 3
|
||||||
visual-testing-customers:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Visual Testing Customers
|
|
||||||
needs: deploy
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Setup Bun
|
|
||||||
uses: ./.github/composite/setup-bun
|
|
||||||
- name: Install dependencies
|
|
||||||
run: bun install --frozen-lockfile
|
|
||||||
- name: Setup Playwright
|
|
||||||
uses: ./.github/actions/setup-playwright
|
|
||||||
- name: Run Playwright tests
|
|
||||||
run: bun e2e-customers
|
|
||||||
env:
|
|
||||||
BASE_URL: ${{needs.deploy.outputs.deployment-url}}
|
|
||||||
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
|
|
||||||
ARGOS_BUILD_NAME: 'customers'
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
if: ${{ !cancelled() }}
|
|
||||||
with:
|
|
||||||
name: playwright-test-results-customers
|
|
||||||
path: packages/gitbook/test-results/
|
|
||||||
retention-days: 3
|
|
||||||
pagespeed-testing:
|
pagespeed-testing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: PageSpeed Testing
|
name: PageSpeed Testing
|
||||||
@@ -285,8 +106,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
@@ -294,7 +117,7 @@ jobs:
|
|||||||
- name: Run pagespeed tests
|
- name: Run pagespeed tests
|
||||||
run: bun ./packages/gitbook/tests/pagespeed-testing.ts $DEPLOYMENT_URL
|
run: bun ./packages/gitbook/tests/pagespeed-testing.ts $DEPLOYMENT_URL
|
||||||
env:
|
env:
|
||||||
DEPLOYMENT_URL: ${{needs.deploy.outputs.deployment-url}}
|
DEPLOYMENT_URL: ${{needs.deploy.outputs.deployment_url}}
|
||||||
PAGESPEED_API_KEY: ${{ secrets.PAGESPEED_API_KEY }}
|
PAGESPEED_API_KEY: ${{ secrets.PAGESPEED_API_KEY }}
|
||||||
format:
|
format:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -302,8 +125,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
@@ -315,8 +140,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
@@ -328,8 +155,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
@@ -340,14 +169,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Build (Open Source)
|
name: Build (Open Source)
|
||||||
env:
|
env:
|
||||||
NPM_TOKEN_READONLY: ''
|
NPMRC_FONT_AWESOME_TOKEN: ''
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install
|
run: bun install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
PUPPETEER_SKIP_DOWNLOAD: 1
|
PUPPETEER_SKIP_DOWNLOAD: 1
|
||||||
- run: bun run build
|
- run: bun run build
|
||||||
@@ -357,8 +188,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
@@ -43,8 +45,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Setup Bun
|
- name: Setup bun
|
||||||
uses: ./.github/composite/setup-bun
|
uses: oven-sh/setup-bun@v1
|
||||||
|
with:
|
||||||
|
bun-version: 1.1.18
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
.next
|
.next
|
||||||
.vercel
|
.vercel
|
||||||
.open-next
|
|
||||||
|
|
||||||
# Generated
|
# Generated
|
||||||
packages/emoji-codepoints/index.ts
|
packages/emoji-codepoints/index.ts
|
||||||
@@ -9,6 +8,3 @@ packages/icons/src/data/*.json
|
|||||||
|
|
||||||
# Build files
|
# Build files
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
README.md
|
|
||||||
CHANGELOG.md
|
|
||||||
@@ -35,10 +35,8 @@ To run a local version of this project, please follow these simple steps.
|
|||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- Node.js (Version: >=20.6)
|
- Node.js (Version: >=18.x)
|
||||||
- Use nvm for easy Node management
|
- Bun
|
||||||
- Bun (Version: >=1.2.1)
|
|
||||||
- We use a text-based lockfile which isn't supported below 1.2.1
|
|
||||||
|
|
||||||
### Set up
|
### Set up
|
||||||
|
|
||||||
@@ -80,26 +78,6 @@ Any published GitBook site can be accessed through your local development instan
|
|||||||
|
|
||||||
All pull-requests will be tested against both visual and performances testing to prevent regressions.
|
All pull-requests will be tested against both visual and performances testing to prevent regressions.
|
||||||
|
|
||||||
## Fonts and Icons
|
|
||||||
|
|
||||||
GitBook Open uses fontawesome. During development, your local environment will use the free version. However, only the pro version will be accepted by CI. If you see the following error:
|
|
||||||
|
|
||||||
```
|
|
||||||
The GitBook icon is missing. It indicates that the dependencies were installed without the correct font-awesome package. These changes have probably been persisted in the Bun lockfile. Read the README for more information.
|
|
||||||
```
|
|
||||||
|
|
||||||
It means that you've changed the GBO dependencies and bundled in the free version. Only GitBook staff can help with this - if you're not on the GitBook team, please ping us in the PR and we'll help get things moving.
|
|
||||||
|
|
||||||
If you are GitBook staff, you'll need our NPM token in your local environment.
|
|
||||||
|
|
||||||
```
|
|
||||||
.env.local
|
|
||||||
|
|
||||||
NPM_TOKEN_READONLY=xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
and then reinstall dependencies.
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
GitBook's rendering engine is fully open source and built on top of [Next.js](https://nextjs.org/). Head to our [contributing guide](https://github.com/GitbookIO/gitbook/blob/main/.github/CONTRIBUTING.md) to learn more about the workflow on adding your first Pull Request.
|
GitBook's rendering engine is fully open source and built on top of [Next.js](https://nextjs.org/). Head to our [contributing guide](https://github.com/GitbookIO/gitbook/blob/main/.github/CONTRIBUTING.md) to learn more about the workflow on adding your first Pull Request.
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
[install.scopes]
|
[install.scopes]
|
||||||
"gitbook" = { token = "$NPM_TOKEN_READONLY", url = "https://registry.npmjs.org" }
|
"awesome.me" = { token = "$NPMRC_FONT_AWESOME_TOKEN", url = "https://npm.fontawesome.com/" }
|
||||||
|
|||||||
+6
-16
@@ -2,24 +2,19 @@
|
|||||||
"name": "gitbook",
|
"name": "gitbook",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@changesets/cli": "^2.27.12",
|
"@changesets/cli": "^2.27.7",
|
||||||
"prettier": "^3.0.3",
|
"prettier": "^3.0.3",
|
||||||
"turbo": "^2.4.1-canary.2",
|
"turbo": "^2.1.2"
|
||||||
"vercel": "^39.3.0"
|
|
||||||
},
|
},
|
||||||
"packageManager": "bun@1.1.18",
|
"packageManager": "bun@1.1.18",
|
||||||
"overrides": {
|
"patchedDependencies": {
|
||||||
"@codemirror/state": "6.4.1",
|
"@vercel/next@4.3.15": "patches/@vercel%2Fnext@4.3.15.patch"
|
||||||
"react": "18.3.1",
|
|
||||||
"react-dom": "18.3.1"
|
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "turbo run dev",
|
"dev": "turbo run dev",
|
||||||
"dev:v2": "turbo run dev:v2",
|
|
||||||
"build": "turbo run build",
|
"build": "turbo run build",
|
||||||
"build:v2": "turbo run build:v2",
|
"build:cloudflare": "turbo run build:cloudflare",
|
||||||
"clean-deps": "rm -rf node_modules && rm -rf packages/*/node_modules",
|
|
||||||
"lint": "turbo run lint",
|
"lint": "turbo run lint",
|
||||||
"lint:fix": "turbo run lint -- --fix",
|
"lint:fix": "turbo run lint -- --fix",
|
||||||
"typecheck": "turbo run typecheck",
|
"typecheck": "turbo run typecheck",
|
||||||
@@ -27,7 +22,6 @@
|
|||||||
"format:check": "prettier ./ --ignore-unknown --list-different",
|
"format:check": "prettier ./ --ignore-unknown --list-different",
|
||||||
"unit": "turbo run unit",
|
"unit": "turbo run unit",
|
||||||
"e2e": "turbo run e2e",
|
"e2e": "turbo run e2e",
|
||||||
"e2e-customers": "turbo run e2e-customers",
|
|
||||||
"changeset": "changeset",
|
"changeset": "changeset",
|
||||||
"release": "turbo run release && changeset publish",
|
"release": "turbo run release && changeset publish",
|
||||||
"release:preview": "turbo run release:preview",
|
"release:preview": "turbo run release:preview",
|
||||||
@@ -36,9 +30,5 @@
|
|||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
]
|
||||||
"patchedDependencies": {
|
|
||||||
"decode-named-character-reference@1.0.2": "patches/decode-named-character-reference@1.0.2.patch",
|
|
||||||
"@vercel/next@4.4.2": "patches/@vercel%2Fnext@4.4.2.patch"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
# @gitbook/cache-do
|
|
||||||
|
|
||||||
## 0.1.1
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- b7a5106: Disable cloudflare observability in production
|
|
||||||
|
|
||||||
## 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
|
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
"default": "./dist/api.js"
|
"default": "./dist/api.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": "0.1.1",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@msgpack/msgpack": "^3.0.0-beta2",
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
||||||
"lru_map": "^0.4.1"
|
"lru_map": "^0.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.5.3",
|
"typescript": "^5.5.3",
|
||||||
"wrangler": "3.82.0"
|
"wrangler": "^3.78.7"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate": "wrangler types --experimental-include-runtime",
|
"generate": "wrangler types --experimental-include-runtime",
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ migrations = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[observability]
|
[observability]
|
||||||
enabled = false
|
enabled = true
|
||||||
|
head_sampling_rate = 0.01
|
||||||
|
|
||||||
[env.preview]
|
[env.preview]
|
||||||
name = "gitbook-open-cache-preview"
|
name = "gitbook-open-cache-preview"
|
||||||
@@ -24,4 +25,4 @@ migrations = [
|
|||||||
|
|
||||||
[env.preview.observability]
|
[env.preview.observability]
|
||||||
enabled = true
|
enabled = true
|
||||||
head_sampling_rate = 0.1
|
head_sampling_rate = 1
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
# next.js
|
|
||||||
/.next/
|
|
||||||
|
|
||||||
# vercel
|
|
||||||
.vercel
|
|
||||||
|
|
||||||
# cloudflare
|
|
||||||
.open-next
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# gitbook-v2
|
|
||||||
|
|
||||||
## 0.1.0
|
|
||||||
|
|
||||||
### Minor Changes
|
|
||||||
|
|
||||||
- cfccc44: Setup structure and deployment for new version
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
# GitBook V2
|
|
||||||
|
|
||||||
This package contains the code for an experiment new version of the GitBook renderer.
|
|
||||||
|
|
||||||
The goals of this new version are:
|
|
||||||
|
|
||||||
- Optimize rendering to leverage Next.js ISR and static rendering
|
|
||||||
- Leverage Node.js runtime and bigger instances to render bigger content
|
|
||||||
- Evaluate Vercel and Cloudflare deployment options
|
|
||||||
|
|
||||||
## Deployment
|
|
||||||
|
|
||||||
#### Vercel
|
|
||||||
|
|
||||||
The new version is deployed automatically to Vercel using a Github Action on every push.
|
|
||||||
|
|
||||||
#### Cloudflare with Opennext-js
|
|
||||||
|
|
||||||
The new version is deployed automatically to Cloudflare using a Github Action on every push.
|
|
||||||
|
|
||||||
## Potential issues
|
|
||||||
|
|
||||||
- [ ] We can't use `dynamicIO` because our root layout needs to fetch the params (https://github.com/vercel/next.js/discussions/71927)
|
|
||||||
- [ ] How to do `nonce` for static resources when we can't use `headers()` (dynamic API) (https://nextjs.org/docs/app/building-your-application/configuring/content-security-policy)
|
|
||||||
|
|
||||||
## Structure
|
|
||||||
|
|
||||||
#### Middleware:
|
|
||||||
|
|
||||||
Goals:
|
|
||||||
- Route between dynamic and static routes
|
|
||||||
- If a token is in the cookies => dynamic route
|
|
||||||
- If a token is in the url => dynamic route
|
|
||||||
- Else => static route
|
|
||||||
- High performances:
|
|
||||||
- It should not rely on data fetching
|
|
||||||
|
|
||||||
#### URLs to support:
|
|
||||||
|
|
||||||
Content URLs:
|
|
||||||
|
|
||||||
- `docs.company.com/page`
|
|
||||||
- Middleware: rewrite to `/static/url/docs.company.com/page`
|
|
||||||
- Page component renders the page
|
|
||||||
- `docs.company2.com/section/page`
|
|
||||||
- Middleware: rewrite to `/static/url/docs.company2.com/section/page`
|
|
||||||
- Page component renders the page
|
|
||||||
- `docs.company3.com/section/sitespace/page`
|
|
||||||
- Middleware: rewrite to `/static/url/docs.company3.com/section/sitespace/page`
|
|
||||||
- Page component renders the page
|
|
||||||
|
|
||||||
Content URLs (adaptive content or visitor authentication):
|
|
||||||
|
|
||||||
- `docs.company.com/page`
|
|
||||||
- Middleware:
|
|
||||||
- If a token is in the cookies or url => dynamic route
|
|
||||||
- Else => rewrite to `/dynamic/url/docs.company.com/page`
|
|
||||||
- Page component renders the page
|
|
||||||
- Read the token from the url query params or cookies
|
|
||||||
|
|
||||||
|
|
||||||
PDF export URLs:
|
|
||||||
|
|
||||||
- `docs.company.com/page/~gitbook/pdf`
|
|
||||||
- Middleware: rewrite to `/dynamic/pdf/docs.company.com/page`
|
|
||||||
- Page component renders the page
|
|
||||||
|
|
||||||
Images resizing:
|
|
||||||
|
|
||||||
- `docs.company.com/~gitbook/image`
|
|
||||||
- Middleware: rewrite to `/dynamic/image/docs.company.com`
|
|
||||||
- Route handlers process the request
|
|
||||||
|
|
||||||
Preview URLs:
|
|
||||||
|
|
||||||
- `open.gitbook.com/sites/site_abc/page` (or `open.gitbook.com/~site/site_abc/page` to stay compatible?)
|
|
||||||
- Middleware: no rewrite
|
|
||||||
- Page component renders the page (dynamic?)
|
|
||||||
- Read the token from the url query params
|
|
||||||
- Read customizations override from the url query params
|
|
||||||
|
|
||||||
|
|
||||||
Space PDF URLs:
|
|
||||||
|
|
||||||
- `open.gitbook.com/spaces/space_abc/pdf`
|
|
||||||
- Middleware: no rewrite
|
|
||||||
- Page component renders the page (dynamic?)
|
|
||||||
- Read the token from the url query params
|
|
||||||
- Read customizations override from the url query params
|
|
||||||
|
|
||||||
Development:
|
|
||||||
|
|
||||||
- `localhost:3000/sites/site_abc/page`
|
|
||||||
|
|
||||||
#### Routes:
|
|
||||||
|
|
||||||
- Content
|
|
||||||
- [ ] `/static/url/[[...url]]/page.tsx`
|
|
||||||
- [ ] `/dynamic/url/[[...url]]/page.tsx`
|
|
||||||
- Images resizing
|
|
||||||
- [ ] `/dynamic/image/[hostname]/route.ts`
|
|
||||||
- PDF export
|
|
||||||
- [ ] `/dynamic/pdf/[[...url]]/page.tsx`
|
|
||||||
- [ ] `/spaces/[space]/pdf/page.tsx`
|
|
||||||
Vendored
-5
@@ -1,5 +0,0 @@
|
|||||||
/// <reference types="next" />
|
|
||||||
/// <reference types="next/image-types/global" />
|
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
|
||||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {import('next').NextConfig}
|
|
||||||
*/
|
|
||||||
const nextConfig = {
|
|
||||||
experimental: {
|
|
||||||
useCache: true,
|
|
||||||
|
|
||||||
// We can't use dynamicIO because it doesn't accept reading params in the root layout
|
|
||||||
// dynamicIO: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default nextConfig;
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
// default open-next.config.ts file created by @opennextjs/cloudflare
|
|
||||||
|
|
||||||
import cache from '@opennextjs/cloudflare/kvCache';
|
|
||||||
|
|
||||||
const config = {
|
|
||||||
default: {
|
|
||||||
override: {
|
|
||||||
wrapper: 'cloudflare-node',
|
|
||||||
converter: 'edge',
|
|
||||||
incrementalCache: async () => cache,
|
|
||||||
tagCache: 'dummy',
|
|
||||||
queue: 'dummy',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
middleware: {
|
|
||||||
external: true,
|
|
||||||
override: {
|
|
||||||
wrapper: 'cloudflare-edge',
|
|
||||||
converter: 'edge',
|
|
||||||
proxyExternalRequest: 'fetch',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
dangerous: {
|
|
||||||
enableCacheInterception: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "gitbook-v2",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"next": "canary",
|
|
||||||
"react": "^19.0.0",
|
|
||||||
"react-dom": "^19.0.0",
|
|
||||||
"@gitbook/api": "^0.93.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@opennextjs/cloudflare": "^0.4.3"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"dev:v2": "next",
|
|
||||||
"build": "next build",
|
|
||||||
"build:v2": "next build",
|
|
||||||
"start": "next start",
|
|
||||||
"build:v2:cloudflare": "opennextjs-cloudflare",
|
|
||||||
"dev:v2:cloudflare": "wrangler dev --port 8771"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { SiteContentLayout } from '@/components/routes/SiteContentLayout';
|
|
||||||
import { createDynamicSiteContext } from '@/lib/context';
|
|
||||||
|
|
||||||
export default async function RootLayout({
|
|
||||||
params,
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
params: Promise<{ url: string[] }>;
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
const { url } = await params;
|
|
||||||
const context = await createDynamicSiteContext(url);
|
|
||||||
|
|
||||||
return <SiteContentLayout context={context}>{children}</SiteContentLayout>;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { SiteContentPage } from '@/components/routes/SiteContentPage';
|
|
||||||
import { createDynamicSiteContext } from '@/lib/context';
|
|
||||||
|
|
||||||
export default async function Page({ params }: { params: Promise<{ url: string[] }> }) {
|
|
||||||
const { url } = await params;
|
|
||||||
const context = await createDynamicSiteContext(url);
|
|
||||||
|
|
||||||
return <SiteContentPage context={context} />;
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { unstable_cacheTag as cacheTag } from 'next/cache';
|
|
||||||
import { SiteContentLayout } from '@/components/routes/SiteContentLayout';
|
|
||||||
import { getSiteCacheTag } from '@/lib/cache';
|
|
||||||
import { createStaticSiteContext } from '@/lib/context';
|
|
||||||
|
|
||||||
export default async function RootLayout({
|
|
||||||
params,
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
params: Promise<{ url: string[] }>;
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
'use cache';
|
|
||||||
|
|
||||||
const { url } = await params;
|
|
||||||
const context = await createStaticSiteContext(url);
|
|
||||||
|
|
||||||
cacheTag(getSiteCacheTag(context.siteId));
|
|
||||||
|
|
||||||
return <SiteContentLayout context={context}>{children}</SiteContentLayout>;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { unstable_cacheTag as cacheTag } from 'next/cache';
|
|
||||||
import { createStaticSiteContext } from '@/lib/context';
|
|
||||||
import { getSiteCacheTag } from '@/lib/cache';
|
|
||||||
import { SiteContentPage } from '@/components/routes/SiteContentPage';
|
|
||||||
|
|
||||||
export default async function Page({ params }: { params: Promise<{ url: string[] }> }) {
|
|
||||||
'use cache';
|
|
||||||
|
|
||||||
const { url } = await params;
|
|
||||||
const context = await createStaticSiteContext(url);
|
|
||||||
|
|
||||||
cacheTag(getSiteCacheTag(context.siteId));
|
|
||||||
|
|
||||||
return <SiteContentPage context={context} />;
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import { GitBookSiteContext } from '@/lib/context';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Layout component to render the site content.
|
|
||||||
*/
|
|
||||||
export async function SiteContentLayout({
|
|
||||||
context,
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
context: GitBookSiteContext;
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
const { api } = context;
|
|
||||||
const { data: publishedSite } = await api.orgs.getPublishedContentSite(
|
|
||||||
context.organizationId,
|
|
||||||
context.siteId,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<html lang="en">
|
|
||||||
<body>
|
|
||||||
<h1>{publishedSite.site.title}</h1>
|
|
||||||
{children}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { GitBookSiteContext } from '@/lib/context';
|
|
||||||
|
|
||||||
export async function SiteContentPage({ context }: { context: GitBookSiteContext }) {
|
|
||||||
const { api } = context;
|
|
||||||
const { data } = await api.orgs.getPublishedContentSite(context.organizationId, context.siteId);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<p>Found site {data.site.id}</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export function getSiteCacheTag(siteId: string) {
|
|
||||||
return `sites/${siteId}`;
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
import { headers } from 'next/headers';
|
|
||||||
import { redirect } from 'next/navigation';
|
|
||||||
import { GitBookAPI } from '@gitbook/api';
|
|
||||||
import { GITBOOK_API_TOKEN, GITBOOK_API_URL, GITBOOK_USER_AGENT } from '@/lib/env';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic context about rendering content.
|
|
||||||
*/
|
|
||||||
export interface GitBookContext {
|
|
||||||
/**
|
|
||||||
* API client to fetch data from GitBook.
|
|
||||||
*/
|
|
||||||
api: GitBookAPI;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Context when rendering a site.
|
|
||||||
*/
|
|
||||||
export interface GitBookSiteContext extends GitBookContext {
|
|
||||||
/**
|
|
||||||
* ID of the organization.
|
|
||||||
*/
|
|
||||||
organizationId: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Site ID.
|
|
||||||
*/
|
|
||||||
siteId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a site context, when rendering a static page.
|
|
||||||
*/
|
|
||||||
export async function createStaticSiteContext(url: string[]): Promise<GitBookSiteContext> {
|
|
||||||
const context = createStaticContext();
|
|
||||||
return fetchSiteContext(url, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a site context, when rendering a dynamic page.
|
|
||||||
*/
|
|
||||||
export async function createDynamicSiteContext(url: string[]): Promise<GitBookSiteContext> {
|
|
||||||
const context = await createDynamicContext();
|
|
||||||
return fetchSiteContext(url, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch the context of a site for a given URL and a base context.
|
|
||||||
*/
|
|
||||||
async function fetchSiteContext(
|
|
||||||
urlParts: string[],
|
|
||||||
baseContext: GitBookContext,
|
|
||||||
): Promise<GitBookSiteContext> {
|
|
||||||
const { api } = baseContext;
|
|
||||||
const url = getURLFromParams(urlParts);
|
|
||||||
const { data } = await api.urls.getPublishedContentByUrl({
|
|
||||||
url,
|
|
||||||
});
|
|
||||||
|
|
||||||
if ('redirect' in data) {
|
|
||||||
redirect(data.redirect);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...baseContext,
|
|
||||||
api: new GitBookAPI({
|
|
||||||
endpoint: api.endpoint,
|
|
||||||
authToken: data.apiToken,
|
|
||||||
userAgent: api.userAgent,
|
|
||||||
}),
|
|
||||||
siteId: data.site,
|
|
||||||
organizationId: data.organization,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the base context when rendering statically.
|
|
||||||
*/
|
|
||||||
function createStaticContext(): GitBookContext {
|
|
||||||
const api = new GitBookAPI({
|
|
||||||
authToken: GITBOOK_API_TOKEN,
|
|
||||||
endpoint: GITBOOK_API_URL,
|
|
||||||
userAgent: GITBOOK_USER_AGENT,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
api,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the base context when rendering dynamically.
|
|
||||||
* The context will depend on the request.
|
|
||||||
*/
|
|
||||||
async function createDynamicContext(): Promise<GitBookContext> {
|
|
||||||
const headersSet = await headers();
|
|
||||||
|
|
||||||
const api = new GitBookAPI({
|
|
||||||
authToken: headersSet.get('x-gitbook-token') ?? GITBOOK_API_TOKEN,
|
|
||||||
endpoint: headersSet.get('x-gitbook-api') ?? GITBOOK_API_URL,
|
|
||||||
userAgent: GITBOOK_USER_AGENT,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
api,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getURLFromParams(input: string[]) {
|
|
||||||
const url = new URL('https://' + input.join('/'));
|
|
||||||
return url.toString();
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* Default GitBook API URL endpoint.
|
|
||||||
*/
|
|
||||||
export const GITBOOK_API_URL = process.env.GITBOOK_API_URL ?? 'https://api.gitbook.com';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default GitBook API token.
|
|
||||||
* It can be use to avoid rate-limiting.
|
|
||||||
*/
|
|
||||||
export const GITBOOK_API_TOKEN = process.env.GITBOOK_API_TOKEN ?? null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User agent to use for API requests.
|
|
||||||
*/
|
|
||||||
export const GITBOOK_USER_AGENT = process.env.GITBOOK_USER_AGENT ?? 'GitBook-Open/2.0.0';
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { NextResponse } from 'next/server';
|
|
||||||
import type { NextRequest } from 'next/server';
|
|
||||||
|
|
||||||
export const config = {
|
|
||||||
matcher: ['/((?!_next/|_static/|_vercel|[\\w-]+\\.\\w+).*)'],
|
|
||||||
};
|
|
||||||
|
|
||||||
export function middleware(request: NextRequest) {
|
|
||||||
// No rewrite
|
|
||||||
return NextResponse.next();
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user