GitBook is a Node.js-based command line tool that can be used to create beautiful e-books, and GitBook provides a large number of plugins to meet various needs.
In this article, the author will record the GitBook installation process in detail, and record the various "moths" that appear in the schoolmates' machines.
Because GitBook depends on node.js, make sure you have installed the node.js environment before installing GitBook. The Node version must not be too high, v12.16.2 is recommended on the Internet, otherwise the following will happen:
1. Install the GitBook command line tool
npm install gitbook-cli -g
Question 1: gitbook : Unable to load file ××××××××× because running scripts is prohibited on this system.
Solve problem one:
- Open Windows PowerShell ISE Search for windows powershell ise in the search box, then right-click to run as administrator;
- Set-ExecutionPolicy RemoteSigned, select all.
2. Install GitBook
gitbook -V
Entering the above command will automatically download GitBook;
Question 2: TypeError: cb.apply is not a function
Solve problem 2: Click on the file indicated in the link to edit the file and comment out the following lines of code
3. Initial build of GitBook project
gitbook init
执行上述命令后,会自动生成两个必要的文件 README.md 和 SUMMARY.md。
README.md: 书的介绍文字,如前言、简介,在章节中也可做为章节的简介。
SUMMARY.md: 定制书籍的章节结构和顺序。
If the following problems occur at this time, it is a problem with the node version:
4. GitBook dependency download
gitbook install
5.GitBook plugin configuration and download
Configure the required plugins in the book.json file "pluginsConfig" (remember to download before referencing). Common plug-ins and detailed explanations
The author's configuration is as follows:
"pluginsConfig": {
"prism": {
"css": [
"prismjs/themes/prism.css"
]
},
"insert-logo": {
"url": "/logoPic/logo.png",
"style": "background:none;max-height:129px;margin-right:200px"
},
"github": {
"url": "https://github.com/zhangjikai"
},
"hide-element": {
"elements": [
".gitbook-link"
]
},
"download-pdf-link": {
"base": "https://www.gitbook.com/book/poppy-project/poppy-docs/",
"label": {
"en": "Download PDF",
"fr": "Télécharger le PDF"
}
}
}
5. GitBook directory configuration
6. GitBook service starts
gitbook serve
7. GitBook service starts
The running result is as follows:
8. GitBook packaging
Type gitbook build
to generate a _book file for deploying the GitBook project. The author has deployed a gitbook project in the Alibaba Cloud server as shown in the figure below. The deployment is the same as the Web project, so I will not explain it in detail here.
attach:
##插入视频
<video controls="controls" width="100%">
<source src="../courseResources/mp4.mp4" type="video/mp4">
</video>
##插入pdf
<embed src="../courseResources/pdf.pdf" width="500" height="375" />
##插入ppt
<embed src="../courseResources/pptTest.pdf" width="100%" height="500px" />
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。