Build node.js environment

Install GCC

If it is already installed, you do not need to install it. Skip this step.

yum install gcc gcc-c++
Copy the code

Download nodejs

Version can be selected in treasure trove tao

Wget HTTP: / / https://npm.taobao.org/mirrors/node/v10.14.1/node-v10.14.1-linux-x64.tar.gzCopy the code

Unpack the

Mkdir /usr/local/node tar -zxvf node-v10.14.1-linux-x64.tar.gz -c /usr/local/nodeCopy the code

Configure the environment

vim /etc/profile

#Add the corresponding path at the bottom
export NODE_HOME=/usr/local/node  
export PATH=$NODE_HOME/bin:$PATH
Copy the code

Refresh the configuration

source /etc/profile
Copy the code

Viewing the Version Number

node -v
npm -v
Copy the code

Build Gitbook

Create a directory

mkdir /usr/local/gitbook
Copy the code

The local installation

npm install gitbook-cli -g
Copy the code

Initialize the

gitbook init
Copy the code

Generating a static Website

Both this command and the following package build can launch a static website

gitbook serve
Copy the code

Pack to build

gitbook build
Copy the code

Access to the effect

Address: http://ip:4000

A new article was added

Use CTRL + C to stop the service. Then, in the Gitbook file, create a new file that ends in.md. If you don’t know how to use Markdown to write your articles, please refer to this article: MarkDown Syntax

Vim buildgitbook.md add the content of the articleCopy the code

Edit the summary. md file:

Vim SUMMARY. Md * [build a GitBook from scratch](buildgitbook.md) add the above line, in fact, this is a hyperlink [] is the name of the display, () is the linkCopy the code

Rerun gitbook Serve.

Add a preview of the article

Summary

Summary shows the directory on the left, which can be used with MD syntax, such as the following unordered directory:

  • Feast taoyuan heroes three sworn enemies cut yellow turbans hero first meritorious service
    • The first time
    • The second time
    • The third back to
  • Zhang Yide whipped the post office in anger and He Guojiu sought to execute the eunuch officials
    • The first time
    • The second time
    • The third back to

Installing a plug-in

Configuration of the book. The json

Create a new file, book.json, in the gitbook directory

After book.json is configured, running Gitbook Install once will automatically load the plug-in.

{
  "title": "This is the Gitbook I tested."."author": "Laugh at the world."."description": "Haven't built one in a while. Build one and play."."language": "zh-hans"."plugins": [
    // Code highlights
    "highlight".// Enhanced search support for Chinese, not supported by default
    "-lunr"."-search"."search-pro".// Return to the top
    "back-to-top-button".// List of articles
    "expandable-chapters".// Display code
    "code".// Adjust the side width
    "splitter".// Bottom copyright
    "tbfed-pagefooter"./ / read the number
    "pageview-count".// Click to view the image
    "popup"./ / theme
    "theme-fexa"]."pluginsConfig": {
   	"page-copyright": {
      "description": "It's just a test game."."signature": "Laugh at the world."."wisdom": "Designer, Frontend Developer & overall web enthusiast"."format": "The 2020-10-28 15:41:26"."copyright": "Copyright © Traveling smile"."timeColor": "# 666"."copyrightColor": "# 666"."utcOffset": "8"."style": "normal"."noPowered": false}}}Copy the code

Results the preview

Run continuously

Create a file

Created in the Gitbook folder

vim start.sh
Copy the code

Write a script

#! /bin/sh

rm -f tpid
nohup gitbook serve > gitbook.log 2>&1 &
echo $! > tpid
echo Start Success!
Copy the code

Script authorization

chmod +777 start.sh
Copy the code

Run the script

sh start.sh
Copy the code

More articles please pay attention to the public number to obtain, search: dust years code things