How to write a book with git

How to write a book with git

Installation Environment

The first step in installing node npm

To detect whether your computer to install the node npm

    # 查看 node 版本
    node -v
     
    # 查看 npm 版本
    npm -v
    复制代码

If successful print publication of this number, state your local have a node operating environment (Installation node default installation npm), but if there is no or an error, then you need to go node official website node to download and install, as:

the left version is recommended stable version installed, that is, has now been officially included in the standard version and the version on the right is the most current version, this version contains some new features, has not yet been fully included in the standard, it could be somewhat change. It is recommended that you install the latest stable version of node development.

The second step globally installed gitbook-cli

Npm recommended Taobao Source:

npm config set registry https://registry.npm.taobao.org/

Then install gitbook -cli

npm i -g gitbook-cli

Third initialization eBook

# 创建一个目录,进入
mkdir gitbook-demo
cd gitbook-demo
 
# 初始化电子书目录
gitbook init 
 
# 编译电子书
gitbook serve 
复制代码

Explain:

After init, there will be two directories and files README.md SUMMARY.md, README.md is a brief description of the e-book, SUMMARY.md is the directory structure of the e-book.

Long directory structure like this:

* [电子书名称](README.md)
* [第一章](chapter1/README.md)
    * [xxxx](chapter1/section1.1.md)
    * [xxxx](chapter1/section1.2.md)
* [第二章](chapter2/README.md)
    * [xxxx](chapter2/section2.1.md)
    * [xxxx](chapter2/section2.2.md)
复制代码

Write SUMMARY.md, execute gitbook init file generated in each folder build directory structure of the file, and then write.

Finally gitbook serve.

gitbook serve command actually first call gitbook build compile books, will open after the completion of a web server listening on local port 4000.

If the current book finished, you want to publish to your own website, you can also use the command output to a file using html

gitbook build [书籍路径] [输出路径]

Finally git when used in conjunction with, need only be performed at the root of books
git init
to create a git repository, and then pulling pleasant - Writing - submitted to the cycle.

Do not forget when submitted ignore module folder, or pull each commit time will be very painful ....

Small expand

You can submit e-books to github, build a gh-pages branch hosted e-book warehouse, local compiled book files (_book directory under the project root directory files) uploaded to the branch, and then You can use this URL to access http://yourUserName.github.io/bookName .

Of course, you can publish to gitbook, visit this site but a bit slow -.-

Guess you like

Origin www.cnblogs.com/liyao0312/p/11334655.html