### Install and Initialize GitBook Embed Source: https://gitbook.com/docs/llms-full.txt/1 Steps to install the @gitbook/embed package, import the createGitBook function, and initialize it with your site URL. ```APIDOC ## Install and Initialize GitBook Embed ### Description Install the `@gitbook/embed` package and initialize the GitBook client with your documentation site URL. ### Installation ```bash npm install @gitbook/embed ``` ### Initialization (JavaScript) ```javascript import { createGitBook } from "@gitbook/embed"; // Or using CommonJS: // const { createGitBook } = require("@gitbook/embed"); const gitbook = createGitBook({ siteURL: "https://docs.company.com", // Replace with your GitBook site URL }); ``` ``` -------------------------------- ### GitBook Agent Style Guide Configuration (Text) Source: https://gitbook.com/docs/documentation/gitbook-agent This text snippet outlines the recommended style for technical writing using GitBook Agent. It emphasizes clear, direct language, accuracy, and structured content. For guides, it suggests a one-sentence summary and well-structured sections. For quickstarts, it mandates a stepper format with action-first, concise steps. This guides users on how to effectively use GitBook Agent for documentation. ```plaintext You are a technical writer at Stripe. Use clear, direct language and prioritize accuracy over flourish. For guides, always introduce the concept with a one-sentence summary and break content into well-structured sections. For quickstarts, always use a stepper and keep every step action-first and concise. ``` -------------------------------- ### Install GitBook Adaptive Content Helper Source: https://gitbook.com/docs/llms-full.txt/1 Installs the necessary GitBook adaptive content helper package using npm. This package is essential for integrating adaptive content features into your application. ```bash npm install @gitbook/adaptive ``` -------------------------------- ### Install GitBook CLI Source: https://gitbook.com/docs/developers/integrations/reference Installs the GitBook CLI globally on your machine using npm. This command is essential for managing GitBook integrations. ```bash npm install @gitbook/cli -g ``` -------------------------------- ### Installing GitBook Adaptive Content Helper Source: https://gitbook.com/docs/llms-full.txt/1 Provides the command to install the GitBook adaptive content helper package using npm. This package is essential for integrating GitBook's adaptive content features into your application, particularly when working with feature flag providers. ```bash npm install @gitbook/adaptive ``` -------------------------------- ### Example API Path with Code Sample Source: https://context7_llms Demonstrates how to include code samples for an API endpoint using OpenAPI. ```APIDOC ## GET /example ### Description Example description for the /example endpoint. ### Method GET ### Endpoint /example ### Parameters #### Query Parameters - **token** (string) - Required - Authorization token. ### Request Example ```yaml openapi: '3.0' info: ... tags: [...] paths: /example: get: summary: Example summary description: Example description operationId: examplePath responses: ... parameters: ... x-codeSamples: - lang: 'cURL' label: 'CLI' source: | curl -L \ -H 'Authorization: Bearer ' \ 'https://api.gitbook.com/v1/user' ``` ### Response #### Success Response (200) - **message** (string) - A success message. ``` -------------------------------- ### Install and Import GitBook Embed Package (JavaScript/TypeScript) Source: https://gitbook.com/docs/llms-full.txt/1 Install the @gitbook/embed package using npm and import the createGitBook function. This sets up your application to interact with GitBook embeds. ```bash npm install @gitbook/embed ``` ```javascript import { createGitBook } from "@gitbook/embed"; ``` ```javascript const { createGitBook } = require("@gitbook/embed"); ``` -------------------------------- ### GitBook Tool Integration Translations Source: https://gitbook.com/docs/documentation/account-management/member-management/roles Contains translations for various tool integrations within GitBook, such as connecting to MCP servers, installing them, and copying URLs. These strings facilitate the setup and management of external tools. ```json { "open_in": "Open in ${1}", "open_in_llms_pre_prompt": "Read ${1} and answer questions about the content.", "connect_mcp_to": "Connect to ${1}", "install_mcp_on": "Install MCP Server on ${1}", "connect_with_mcp": "Connect with MCP", "copy_mcp_url": "Copy the MCP Server URL" } ``` -------------------------------- ### Configuring LaunchDarkly with GitBook Adaptive Content (React) Source: https://gitbook.com/docs/llms-full.txt/1 Illustrates how to configure a React application to pass LaunchDarkly feature flag context to GitBook using the `withLaunchDarkly` helper. This involves using `asyncWithLDProvider` from `launchdarkly-react-client-sdk` and the `useLDClient` hook to manage the client and pass it to the GitBook helper. The code sets up the LaunchDarkly provider and renders the application, ensuring feature flags are available to GitBook. ```javascript import { render } from 'react-dom'; import { withLaunchDarkly } from '@gitbook/adaptive'; import { asyncWithLDProvider, useLDClient } from 'launchdarkly-react-client-sdk'; import MyApplication from './MyApplication'; function PassFeatureFlagsToGitBookSite() { const ldClient = useLDClient(); React.useEffect(() => { if (!ldClient) { return; } return withLaunchDarkly(ldClient); }, [ldClient]); return null; } (async () => { const LDProvider = await asyncWithLDProvider({ clientSideID: 'client-side-id-123abc', context: { kind: 'user', key: 'user-key-123abc', name: 'Sandy Smith', email: 'sandy@example.com' }, options: { /* ... */ } }); render( , document.getElementById('reactDiv'), ); })(); ``` -------------------------------- ### OpenAPI Block Example Source: https://context7_llms This example shows how to embed an OpenAPI specification into a GitBook page, allowing users to interact with API endpoints directly. ```APIDOC ## POST /pet ### Description Adds a new pet to the store. Handles the creation of a new pet resource. ### Method POST ### Endpoint /pet ### Parameters #### Request Body - **name** (string) - Required - Name of the pet - **photoUrls** (array of string) - Required - URLs of the pet's photos - **id** (integer) - Optional - Unique identifier for the pet - **category** (object) - Optional - Category of the pet - **id** (integer) - Optional - Category ID - **name** (string) - Optional - Category name - **tags** (array of object) - Optional - Tags associated with the pet - **id** (integer) - Optional - Tag ID - **name** (string) - Optional - Tag name - **status** (string) - Optional - Status of the pet (e.g., available, pending, sold) ### Request Example ```json { "name": "doggie", "photoUrls": [ "string" ], "id": 0, "category": { "id": 0, "name": "string" }, "tags": [ { "id": 0, "name": "string" } ], "status": "available" } ``` ### Response #### Success Response (200) - **id** (integer) - Unique identifier for the pet - **name** (string) - Name of the pet - **photoUrls** (array of string) - URLs of the pet's photos - **category** (object) - Category of the pet - **id** (integer) - Category ID - **name** (string) - Category name - **tags** (array of object) - Tags associated with the pet - **id** (integer) - Tag ID - **name** (string) - Tag name - **status** (string) - Status of the pet #### Response Example ```json { "id": 10, "name": "doggie", "photoUrls": [ "string" ], "category": { "id": 1, "name": "Dogs" }, "tags": [ { "id": 1, "name": "friendly" } ], "status": "available" } ``` ``` -------------------------------- ### Configure GitBook with .gitbook.yaml Source: https://context7_llms This snippet shows a basic configuration for Git Sync using a .gitbook.yaml file. It specifies the root directory for documentation, the README file, and the SUMMARY file. It also includes an example of how to set up redirects. ```yaml root: ./ ​structure: readme: README.md summary: SUMMARY.md​ redirects: previous/page: new-folder/page.md ``` -------------------------------- ### Install GitBook Embed Package Source: https://gitbook.com/docs/llms-full.txt/1 Installs the necessary @gitbook/embed package into your React project using npm. This is a prerequisite for using GitBook's React components. ```bash npm install @gitbook/embed ``` -------------------------------- ### Configure Application with Reflag and GitBook Adaptive SDK (React) Source: https://gitbook.com/docs/llms-full.txt/1 Demonstrates how to configure a React application to pass Reflag feature flags as claims to GitBook using the `withReflag` helper from `@gitbook/adaptive` and `ReflagProvider` from `@reflag/react-sdk`. This setup ensures that user-specific feature flags are available within the GitBook site for content personalization. It requires a Reflag publishable key and user/company information. ```javascript import { withReflag } from '@gitbook/adaptive'; import { ReflagProvider, useClient } from '@reflag/react-sdk'; import MyApplication from './MyApplication'; function PassFeatureFlagsToGitBookSite() { const client = useClient(); React.useEffect(() => { if (!client) { return; } return withReflag(client); }, [client]); return null; } export function Application() { const currentUser = useLoggedInUser(); const appConfig = useAppConfig(); return ( ); } ``` -------------------------------- ### POST /api/v3/pet (JavaScript Example) Source: https://gitbook.com/docs/documentation/api-references/openapi Adds a new pet to the store using JavaScript's fetch API. This example demonstrates sending JSON data in the request body. ```APIDOC ## POST /api/v3/pet (JavaScript Example) ### Description Adds a new pet to the store using JavaScript's fetch API. This example demonstrates sending JSON data in the request body. ### Method POST ### Endpoint /api/v3/pet ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **id** (integer) - Required - The ID of the pet - **name** (string) - Required - The name of the pet - **category** (object) - Optional - The category of the pet - **photoUrls** (array of strings) - Required - URLs of the pet's photos - **tags** (array of objects) - Optional - Tags associated with the pet - **status** (string) - Optional - The status of the pet (e.g., available, pending, sold) ### Request Example ```javascript const response = await fetch('/api/v3/pet', { method: 'POST', headers: { "Authorization": "Bearer YOUR_OAUTH2_TOKEN", "Content-Type": "application/json" } }); const data = await response.json(); ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the pet was added successfully. #### Response Example ```json { "message": "Pet added successfully" } ``` ``` -------------------------------- ### Create GitBook Client Instance (JavaScript) Source: https://gitbook.com/docs/llms-full.txt/1 Creates a GitBook client instance, which is necessary for interacting with GitBook embed functionalities. Requires the URL of your GitBook documentation site. ```javascript import { createGitBook } from '@gitbook/embed'; const gitbook = createGitBook({ siteURL: 'https://docs.company.com' }); ``` -------------------------------- ### HTTP POST Request with Content-Length Example Source: https://gitbook.com/docs/documentation/api-references/openapi An example of an HTTP POST request that includes the 'Content-Length' header, indicating the size of the request body. This is crucial for servers to correctly parse the incoming data. ```http POST /api/v3/pet HTTP/1.1 Authorization: Bearer YOUR_OAUTH2_TOKEN Content-Type: application/xml Accept: */* Content-Length: 133 ``` -------------------------------- ### Initialize GitBook Client and Create Embed Iframe (JavaScript) Source: https://gitbook.com/docs/llms-full.txt/1 Initialize the GitBook client with your site URL and create an iframe element for the embed. This iframe can be configured with visitor tokens for authenticated access. ```javascript const gitbook = createGitBook({ siteURL: "https://docs.company.com", }); const iframe = document.createElement("iframe"); iframe.src = gitbook.getFrameURL({ visitor: { token: 'your-jwt-token', // Optional: for Adaptive Content or Authenticated Access unsignedClaims: { // Optional: custom claims for dynamic expressions userId: '123', plan: 'premium' } } }); iframe.id = "gitbook-embed-container"; iframe.style.border = "none"; iframe.style.width = "100%"; iframe.style.height = "600px"; ``` -------------------------------- ### Example Monorepo Directory Structure Source: https://context7_llms Illustrates a typical directory structure for a monorepo that can be synchronized with multiple GitBook spaces. Each subdirectory can contain its own `.gitbook.yaml` file to define its configuration. ```tree / package.json packages/ styleguide/ .gitbook.yaml README.md SUMMARY.md app/ README.md SUMMARY.md api/ .gitbook.yaml README.md SUMMARY.md ``` -------------------------------- ### HTTP POST Request Example Source: https://gitbook.com/docs/documentation/api-references/openapi Demonstrates a basic HTTP POST request to an API endpoint. Includes headers for authorization, content type, and accept. This example is language-agnostic as it represents an HTTP request. ```http POST /api/v3/pet HTTP/1.1 Authorization: Bearer YOUR_OAUTH2_TOKEN Content-Type: application/xml Accept: */* ``` -------------------------------- ### Allow self-merge for minor changes (JavaScript) Source: https://context7_llms This JavaScript expression allows the creator of a change request to merge it themselves only if the subject starts with '[minor]'. For all other cases or if the subject does not start with '[minor]', it defaults to allowing the merge. This provides flexibility for small, non-critical updates. ```javascript changeRequest.createdBy.id === actor.id ? changeRequest.subject.startsWith("[minor]") : true ``` -------------------------------- ### Initialization and Widget Control Source: https://gitbook.com/docs/llms-full.txt/1 This section covers initializing the GitBook widget and controlling its visibility and state. ```APIDOC ## Initialization and Widget Control ### Initialize Widget * `GitBook('init', options: { siteURL: string }, frameOptions?: { visitor?: {...} })` - Initialize the GitBook widget with the site URL and optional authenticated access. ### Widget Control * `GitBook('show')` - Show the widget button. * `GitBook('hide')` - Hide the widget button. * `GitBook('open')` - Open the widget window. * `GitBook('close')` - Close the widget window. * `GitBook('toggle')` - Toggle the widget window. ``` -------------------------------- ### JSON: Example of Visitor Claims with isEnterprise Set Source: https://gitbook.com/docs/guides/product-guides/how-to-personalize-your-gitbook-site-using-auth0-and-adaptive-content This JSON object represents an example of visitor claims, where the 'isEnterprise' property is explicitly set to true. This is useful for testing or demonstrating how claims are structured after being set by Auth0. ```json { "isEnterprise": true } ```