Files
gitbook/README.md
T
Samy Pessé a4ec3c8c53 Refactor routing logic for production to support multi-tenancy (#7)
* Move back to use the middleware as the main logic

* Fix link

* Improve lookup to support docs.gitbook.com.localhost:3000

* Make it work with dev url in prod for now

* Start lookup with API

* Continue

* Prepare for cloudflare build

* Dummy commit

* Try to abort requests

* Support x-forwarded-host

* Test multiple modes

* Add logs

* Add logs

* Update next

* Default to multi-path

* Switch back to nodejs runtime

* Adapt to staging API

* Make sure to return an absolute url for a redirect

* Update api client and try single request

* Try again with concurrent lookup
2023-11-21 16:53:02 +01:00

49 lines
1.6 KiB
Markdown

# GitBook
Next.js application to render GitBook published content.
## Self-hosting
This repository is designed to allow self-hosting the rendering of your GitBook published content. Self-hosting has pros and cons, on the pro side you can customize the look and feel and better embed your documentation in your application; on the cons side you become responsible for the reliability and keeping the renderer up-to-date with the changes on the GitBook platform.
This application can easily be configured and deployed on Vercel or Cloudflare to serve a specific space content (**self-hosting**). It requires a minimum amount of configuration:
- `GITBOOK_MODE=single`
- `GITBOOK_SPACE_ID`: ID of the GitBook.com space to render
- `GITBOOK_TOKEN`: a GitBook.com API token that has access to the space defined in `GITBOOK_SPACE_ID`
## Development
#### Installation
Clone the repository and use [Bun](https://bun.sh/) to install dependencies and run the local development server.
```
bun install
```
#### Local Configuration
To develop and test a GitBook space locally (`http://localhost:3000/<spaceId>/**`), first create a [GitBook API token](https://app.gitbook.com/account/developer) and put it in a `.env.local` file:
```
GITBOOK_TOKEN=gb_api_abc
```
This step is not required when developing using URL lookup (`http://<host>.localhost:3000/<path>`).
#### Start the local server
Run the Next.js development server.
```
bun dev
```
Then open the space in your web browser, using `http://localhost:3000/<url>` (example: `http://localhost:3000/docs.gitbook.com`).
#### Other development commands
- `bun format`: format the code
- `bun lint`: lint the code