GitBook Tutorial

 

background

Due regard scattered knowledge before they are written in  Gist  , the time you are looking for is not very systematic, so I plan to be moved  GitBook  up unified management, and  GitBook  After writing the compiler can generate static pages posted to the blog, grid full force look.

GitBook Profile

GitBook preparations

Install Node.js

GitBook is a Node.js based command-line tool, download and install  Node.js , after the installation is complete, you can use the following command to verify that the installation was successful.

$ node -v
v7.7.1

Installation GitBook

Enter the following command to install GitBook.

$ npm install gitbook-cli -g

After the installation is complete, you can use the following command to verify that the installation was successful.

$ gitbook -V
CLI version: 2.3.2
GitBook version: 3.2.3 

For more details, please refer to  GitBook installation documentation  to install GitBook.

Installation GitBook Editor

Go  GitBook official website to  download GitBook editor; If you're a Mac user and installed  brew cask , then you can use the  brew cask install gitbook-editor command line to install GitBook editor.

Preview

After GitBook ready to do a good job, we enter the one you're writing a book directory, enter the following command.

$ gitbook init
warn: no summary file in this book
info: create README.md info: create SUMMARY.md info: initialization is finished 

You can see that he would create README.md and SUMMARY.md these two documents, README.md should not be unfamiliar, it is the documentation, and book chapters SUMMARY.md is actually a directory, its default contents are as follows:

# Summary

* [Introduction](README.md)

Next, we enter  $ gitbook serve the command, then enter in the browser address bar  http://localhost:4000 can preview books.

Results as shown below:

 

After running the command generates a folder in the books  _book folder containing the content that is generated html file, we can use the following command to generate the page rather than on the server.

gitbook build

Below we explain in detail the directory structure under GitBook and related documents.

Directory Structure

GitBook basic directory structure is shown below:

.
├── book.json
├── README.md
├── SUMMARY.md ├── chapter-1/ | ├── README.md | └── something.md └── chapter-2/ ├── README.md └── something.md 

Let's say something about book.json and SUMMARY.md main file.

book.json

This file is mainly used to store configuration information, I will release my profile.

{
    "title": "Blankj's Glory", "author": "Blankj", "description": "select * from learn", "language": "zh-hans", "gitbook": "3.2.3", "styles": { "website": "./styles/website.css" }, "structure": { "readme": "README.md" }, "links": { "sidebar": { "我的狗窝": "https://blankj.com" } }, "plugins": [ "-sharing", "splitter", "expandable-chapters-small", "anchors", "github", "github-buttons", "donate", "sharing-plus", "anchor-navigation-ex", "favicon" ], "pluginsConfig": { "github": { "url": "https://github.com/Blankj" }, "github-buttons": { "buttons": [{ "user": "Blankj", "repo": "glory", "type": "star", "size": "small", "count": true } ] }, "donate": { "alipay": "./source/images/donate.png", "title": "", "button": "赞赏", "alipayText": " " }, "sharing": { "douban": false, "facebook": false, "google": false, "hatenaBookmark": false, "instapaper": false, "line": false, "linkedin": false, "messenger": false, "pocket": false, "qq": false, "qzone": false, "stumbleupon": false, "twitter": false, "viber": false, "vk": false, "weibo": false, "whatsapp": false, "all": [ "google", "facebook", "weibo", "twitter", "qq", "qzone", "linkedin", "pocket" ] }, "anchor-navigation-ex": { "showLevel": false }, "favicon":{ "shortcut": "./source/images/favicon.jpg", "bookmark": "./source/images/favicon.jpg", "appleTouch": "./source/images/apple-touch-icon.jpg", "appleTouchMore": { "120x120": "./source/images/apple-touch-icon.jpg", "180x180": "./source/images/apple-touch-icon.jpg" } } } } 

I believe that many nodes themselves would have guessed what it meant, I was briefly under the bar.

title

The book title

author

Author

description

This book describes

language

This book language, Chinese setting "zh-hans" can

gitbook

Specifies the version of GitBook

styles

Custom page styles

structure

Specifies the Readme, Summary, Glossary and Languages ​​corresponding file name

links

Add a link information in the left navigation bar

plugins

Configure the plugin to use

pluginsConfig

Plug-in configuration properties

SUMMARY.md

This file is mainly determined GitBook chapter directory, which is represented by the parent-child relationship file list in Markdown syntax, here is a simple example:

# Summary

* [Introduction](README.md) * [Part I](part1/README.md) * [Writing is nice](part1/writing.md) * [GitBook is nice](part1/gitbook.md) * [Part II](part2/README.md) * [We love feedback](part2/feedback_please.md) * [Better tools for authors](part2/better_tools.md) 

This configuration corresponds to the directory structure is shown below:

 

We use  标题 or  水平分割线 the GitBook divided into several different portions, as follows:

# Summary

### Part I

* [Introduction](README.md) * [Writing is nice](part1/writing.md) * [GitBook is nice](part1/gitbook.md) ### Part II * [We love feedback](part2/feedback_please.md) * [Better tools for authors](part2/better_tools.md) --- * [Last part without title](part3/title.md) 

This configuration corresponds to the directory structure is shown below:

 

Plug

GitBook have  plug-in's official website , the default with five plug-in, highlight, search, sharing, font -settings, livereload, if you want to remove the built-in plug-ins can be added in front of the plug-in name  -, for example:

"plugins": [
    "-search"
]

如果要配置使用的插件可以在 book.json 文件中加入即可,比如我们添加 plugin-github,我们在 book.json 中加入配置如下即可:

{
    "plugins": [ "github" ], "pluginsConfig": { "github": { "url": "https://github.com/your/repo" } } } 

然后在终端输入 gitbook install ./ 即可。

如果要指定插件的版本可以使用 [email protected],因为一些插件可能不会随着 GitBook 版本的升级而升级。

结语

这是我对 GitBook 使用的总结,希望能帮到今后需要的小伙伴。

Guess you like

Origin www.cnblogs.com/yunlongaimeng/p/11490074.html