Skip to content

Improved documentation for gitbookConfigURL #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,28 @@ Put this in your book.json:
A `<select>` element will be created with the given `options` and placed at the top of the book summary. When the user selects one of the options, they are taken to that URL.

The `gitbookConfigURL` variable is a publicly accessible URL to your `book.json`. If this is present, the plugin will fetch the latest config when the page loads, so even older versions of your book will have updated `options`.
However, each version of your book needs to have book.json, which defines the `gitbookConfigURL` variable. It should also define at least an option for the current version, with `selected` set to true.
The list of options will be overwritten by the config in `gitbookConfigURL`, but the current selected version will be matched according the value (URL) of the previous selected option.

#### An example how to define 2 versions with a common config

Let's have 2 versions in branches v1 and v2. We want to define a common config in another branch/repository, so that we need to update only single config file if we add new versions later.

1. Create a completely new branch (can be empty) or a new empty repository
2. Create a `book.json` file in the new config branch/repo with configuration for `versions` plugin in `pluginsConfig`. Define options with value and text for v1 and v2.
3. Create a `book.json` file in v1 and v2 branches as in the above example. Add `gitbookConfigURL` pointing to raw book.json file in your config branch
4. For both v1 and v2 branches, add single element into `options` in book.json - the`value` should point to the gitbooks URL matching the v1 or v2 branch, the `text` is the label s defined in the conig branch, and `selected` should be set to true

You will end up with 3 `book.json` files in 3 branches. Branch v1 contains a single option pointing to the v1 documentation, v2 contains again a single option pointing to the v2 documentation. Both also contain referece to the common book.json config in another branch.
The book.json file in the config branch is the only file you need to modify from now on.

Let's add a new version:

1. Create v3 branch (based on v2 branch)
2. Modify `book.json` acordingly - update the value with correct v3 URL and text (label)
3. Modify `book.json` in config branch - copy the option from v3 branch (after modifications) and add it to the list of options

And you are done. All 3 options will be available in all 3 versions of the documentation.

### Credits

Expand Down