gitbook

nvm node npm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
source ~/.zshrc
nvm install node
npm config set registry https://registry.npm.taobao.org

gitbook

npm install gitbook-cli -g

gitbook 常见命令

List installed versions:

gitbook ls

List available versions on NPM:

gitbook ls-remote

Install a specific version:

gitbook fetch 2.1.0
# or a pre-release
gitbook fetch beta

Update to the latest version

gitbook update

Uninstall a specific version

gitbook uninstall 2.0.1

使用

gitbook init
gitbook serve (该命令首先会执行 gitbook build 编译书籍, 完成以后会打开一个 web 服务器, 监听在本地的 4000 端口)

plugin

安装方法

在 git book 项目的根目录下执行

npm install <plugin_name>

常用 plugins 列表

gitbook-plugin-page-toc

  1. install this plugin
npm install gitbook-plugin-page-toc
  1. add below code to book.json under the root dir of your git book repo
{
  "plugins": [ "page-toc" ],
  "pluginsConfig": {
  }
}

gitbook-plugin-todo

  1. install this plugin
npm install --save gitbook-plugin-todo
  1. add below code to book.json under the root dir of your git book repo
{
    "plugins": ["todo"]
}

gitbook-plugin-toggle-chapters

  1. install this plugin
npm install gitbook-plugin-toggle-chapters
  1. add below code to book.json under the root dir of your git book repo
{
    "plugins": ["toggle-chapters"]
}

gitbook-plugin-youtubex

  1. install this plugin
git clone https://github.com/ymcatar/gitbook-plugin-youtubex node_modules/gitbook-plugin-youtubex
  1. add below code to book.json under the root dir of your git book repo
    "plugins": ["youtubex"]
    "pluginsConfig": {
    "youtubex": {
        "embedDescription": {
        "en": "Watch this video!",
        "de": "Eingebettetes video:"
        }
    }
    }

jadu/gitbook-theme

  1. clone theme project
git clone https://github.com/jadu/gitbook-theme.git
cp -r gitbook-theme/assets node_modules/
  1. add below code to book.json under the root dir of your git book repo
    "styles":{
        "website": "assets/continuum/cxm.css"
    }
  1. 执行命令
gitbook install