GitBook使用教程

通过npm安装

1
npm install gitbook-cli -g

创建两个文件

README.md

1
2
# Introduction
说明文档

SUMMARY.md

1
2
3
4
5
6
7
8
9
# Summary

* [Introduction](README.md)
* [section1](section1/README.md)
* [example1](section1/example1.md)
* [example2](section1/example2.md)
* [section2](section2/README.md)
* [example1](section2/example1.md)
* [example2](section2/example2.md)

初始化目录文件

1
gitbook init

预览书籍

1
gitbook serve

编译文件

1
gitbook build

使用插件

创建 book.json 文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
"title": "GitBook",
"author" : "echo",
"output.name": "site",
"description" : "电子书",
"language" : "zh-hans",
"gitbook" : "3.2.3",
"root": ".",
"links" : {
"sidebar" : {
"Home" : "https://zhx2020.github.io"
}
},
"styles": {
"website": "styles/website.css",
"ebook": "styles/ebook.css",
"pdf": "styles/pdf.css",
"mobi": "styles/mobi.css",
"epub": "styles/epub.css"
},
"plugins": [
"-lunr",
"-search",
"back-to-top-button",
"highlight",
"search-plus",
"expandable-chapters",
"chapter-fold",
"splitter",
"-prism",
"github",
"github-buttons",
"tbfed-pagefooter",
"edit-link",
"copy-code-button",
"simple-page-toc",
"anchor-navigation-ex"
],
"pluginsConfig": {
"theme-default": {
"showLevel": false
},
"prism": {
"css": [
"prism-themes/themes/prism-base16-ateliersulphurpool.light.css"
]
},
"github": {
"url": "https://github.com/zhx2020"
},
"github-buttons": {
"repo": "zhx2020/gitbook",
"types": [
"star",
"watch",
"fork"
],
"size": "small"
},
"tbfed-pagefooter": {
"copyright":"Copyright &copy zhx2020.github.io 2020",
"modify_label": "该文件修订时间:",
"modify_format": "YYYY-MM-DD HH:mm:ss"
},
"edit-link": {
"base": "https://github.com/zhx2020/gitbook/edit/master",
"label": "Edit This Page"
},
"simple-page-toc": {
"maxDepth": 3,
"skipFirstH1": true
},
"anchor-navigation-ex": {
"showLevel": false,
"showGoTop": false
}
}
}

安装插件

1
gitbook install

书籍部署

将编译后的 _book 文件部署到 github ,配置 page 。

在线预览

GitBook电子书