来自官网的介绍
GitBook is a modern publishing toolchain. Making both writing and collaboration easy.
GitBook 是一个基于 Node.js 的命令行工具,可使用 Github/Git 和 Markdown 来制作精美的电子书,GitBook 并非关于 Git 的教程。
GitBook支持输出多种文档格式:
微信小程序使用手册 https://wechats.github.io/tinyapp-doc/
$ npm install gitbook-cli -g
$ gitbook init [目录名]
这时会在对应目录下生成 README.md 和 SUMMARY.md。 README.md 即为书的简介,会作为书的第一页显示。 SUMMARY.md 是书的目录,是 Gitbook 生成电子书的文件索引。
{
"plugins": [
"betterchinese",
"-duoshuo",
"highlight",
"lunr",
"baidu_gio",
"search",
"fontsettings",
"theme-default",
"toolbar",
"sharing"
],
"pluginsConfig": {
"lunr": {
"maxIndexSize": 1000000,
"ignoreSpecialCharacters": false
},
"baidu_gio": {
"token": "Your Token"
},
"toolbar": {
"buttons":
[
{
"label": "GitHub",
"icon": "fa fa-github",
"url": "https://github.com/wechats/tinyapp-doc"
},
{
"label": "PDF",
"icon": "fa fa-file-pdf-o",
"url": "https://wechats.github.io/tinyapp-doc/gen/tinyapp-doc.pdf"
}
]
},
"sharing": {
"facebook": false,
"twitter": false,
"google": false,
"weibo": true,
"instapaper": false,
"vk": false,
"all": ["weibo"]
}
}
}
book.json 是 Gitbook 的配置文件,plugins 元素定义 Gitbook 需要哪些插件,开头有‘-’代表禁用某个插件,pluginsConfig 定义某个插件的配置。 Gitbook 默认包含的插件分别是:
* highlight
* search
* lunr
* sharing
* fontsettings
* theme-default
如果想安装新插件,只需要先查询到插件名,然后写到 plugins 里面,再执行
$ gitbook install
Gitbook 会自动安装并使用新插件。
当编辑完 Gitbook,我们可以通过以下命令进行测试:
$ gitbook serve
然后访问 http://localhost:4000 就能看到书的效果
通过以下命令,可以输出 Gitbook 静态网站到 _book 文件夹
$ gitbook build
$ gitbook pdf
$ gitbook mobi
$ gitbook epub
Gitbook 官网: https://www.gitbook.com
Gitbook Github: https://github.com/GitbookIO/gitbook
Gitbook Editor: https://www.gitbook.com/editor
Gitbook 插件页:http://plugins.gitbook.com
Gitbook 官方手册:http://toolchain.gitbook.com