3.4.1. 前言

GitBook 的配置存储文件为 book.json。该文件可以配置本书的基本信息与安装插件等,具体配置都是可选的,如果不配置则默认输出。

{
    "title": "",
    "author": "",
    "description": "",
    "language": "",
    "gitbook": "",
    "root": "",
    "links": {
    },
    "plugins": [
    ],
    "pluginsConfig": {
    }
}

3.4.2. title

设置书本的标题

{
    "title" : "How to use GitBook"
}

3.4.3. author

作者的相关信息

{
  "author" : "GitBook Author"
}

3.4.4. description

本书的简单描述

{
  "description": "记录 GitBook 的基本使用"
}

3.4.5. language

GitBook 使用的语言, 版本 v2.6.4 中可选的语言如下:

en, ar, bn, cs, de, en, es, fa, fi, fr, he, it, ja, ko, no, pl, pt, ro, ru, sv, uk, vi, zh-hans, zh-tw

配置使用简体中文

{
  "language" : "zh-hans"
}

3.4.6. gitbook

指定使用的 gitbook 版本

{
  "gitbook": "3.2.3",
  "gitbook": ">=3.0.0"
}

3.4.7. root

指定存放 GitBook 文件(除了 book.json)的根目录

{
  "root": "."
}

对于软件项目,你可以使用子目录(如 docs/)来存储项目的文档,目录结构如下:

.
├── book.json
└── docs/
    ├── README.md
    └── SUMMARY.md

book.json 中配置:

{
    "root": "./docs"
}

3.4.8. links

在左侧导航栏添加链接信息

{
  "links" : {
      "sidebar" : {
          "Home" : "https://gitbook.com"
      }
  }
}

3.4.9. styles

自定义页面样式, 默认情况下各generator对应的css文件

{
  "styles": {
      "website": "styles/website.css",
      "ebook": "styles/ebook.css",
      "pdf": "styles/pdf.css",
      "mobi": "styles/mobi.css",
      "epub": "styles/epub.css"
  }
}

例如使<h1> <h2>标签有下边框,可以在 website.css 中设置

h1 , h2{
    border-bottom: 1px solid #EFEAEA;
}

3.4.10. plugins

配置使用的插件

{
  "plugins": [
      "disqus"
  ]
}

添加新插件之后需要运行gitbook install来安装新的插件

GitBook默认带有5个插件:

  • highlight
  • search
  • sharing
  • font-settings
  • livereload

如果要去除自带的插件, 可以在插件名称前面加 -

{
  "plugins": [
      "-search"
  ]
}

3.4.11. pluginsConfig

配置插件的属性

{
  "pluginsConfig": {
      "disqus": {
          "shortName": "XXXXXXX"
      }
  }
}

3.4.12. structure

指定 Readme、Summary、Glossary 和 Languages 对应的文件名,下面是这几个文件对应变量以及默认值:

变量 含义和默认值
structure.readme Readme file name (defaults to README.md)
structure.summary Summary file name (defaults to SUMMARY.md)
structure.glossary Glossary file name (defaults to GLOSSARY.md)
structure.languages Languages file name (defaults to LANGS.md)

3.4.13. .gitignore

在 GitBook 中,你可以在根目录增加 .gitigonre.bookignore.ignore 来进行忽略文件。这样,GitBook 就不对读取该文件了,下面是 文件内容示例,可以忽略 test.md 文件和 bin 目录下的所有文件:

# This is a comment

# Ignore the file test.md
test.md

# Ignore everything in the directory "bin"
bin/*
Copyright © MinGRn 2018 all right reserved,powered by Gitbook最近修订时间: 2019-03-26

results matching ""

    No results matching ""