GitBook 使用指北

安装cli: mkdir GitBook && cd GitBook && npm install gitbook-cli -g

查看是否安装成功: gitbook -V

创建书籍目录:

bookRoot
├── 1-FirstChapter // The first chapter,format: {orderNumber or alphabet}-{chapterName}.md
├────── 1-FirstDocument.md
├────── 5-SecondDocument.md // concentrating solely on the order, not the numbers.
├── 3-SecondChapter // Focus only on the order, not the numbers.
├────── 1-FirstDocumentOfSecondChapter.md
├────── 2-SecondDocumentOfSecondChapter.md
├── 7-ThirdChapter
├── FourthChapter // May have no order
├── README.md // In addition to readme.md, not to put other markdown documents
└── book.json // Set up the book

安装SUMMARY.md自动生成插件: npm install -g gitbook-summary

执行 book sm , 自动生成 SUMMARY.md

创建 book.json

{
"title": "xxx",
"description": "",
"author": "",
"language": "zh-hans",
"ignores": [
"_book",
"node_modules"
],
"plugins": [
"outline"
]
}

生成html: gitbook build ,运行该命令后会生成 _book 文件夹, 里面的内容即为生成的 html 文件

本地预览: gitbook serve,然后在浏览器地址栏中输入 http://localhost:4000

生成pdf: