Gitbook编写JSON文件
title: Gitbook编写JSON文件 # 标题
date: 2020-10-31 16:34:30
updated: 2020-12-31
categories:
- 前端
tags: - JSON
- Gitbook
Gitbook优化之编写JSON文件
- Gitbook init后续优化
gitbook init
命令是为了根据你提供的文件夹名字,在你的文件夹中生成一个README.md和SUMMARY.md文件README.md文件,不能删除,是为你的电子书提供提纲
SUMMARY.md文件也不能删除,是你的电子书的目录
一、Gitbook后续插件
没有_book
在gitbook serve之后出现的是_book
二、安装插件
- 多级目录插件
在默认主题下面,安装一个插件,快速回到开头的一个插件
在我的GitBook项目根目录下编写book.json
{
"plugins" : [ "back-to-top-button" ]
}
然后
D:\___MyGitbook\DOS>gitbook install
info: installing 1 plugins using npm@3.9.2
info:
info: installing plugin "back-to-top-button"
info: install plugin "back-to-top-button" (*) from NPM with version 0.1.4
D:\___MyGitbook\DOS
`-- gitbook-plugin-back-to-top-button@0.1.4
info: >> plugin "back-to-top-button" installed with success
效果还不错。
三、JSON文件格式
{
"title": "DOS教程",
"author": "HACV",
"description": "选择学校",
"language": "zh-hans",
"gitbook": "3.2.3",
"links": {
"sidebar": {
"个人博客": "https://hacv.gitee.io/"
}
},
"plugins": [
"back-to-top-button",
"chapter-fold",
"github",
"insert-logo",
"tbfed-pagefooter",
"code",
"copy-code-button",
"flexible-alerts"
],
"pluginsConfig":
{
"github":
{
"url": "https://github.com/HACV"
},
"insert-logo":
{
"url": "https://portrait.gitee.com/uploads/avatars/user/2599/7799986_HACV_1603894099.png!avatar200",
"style": "background: none; max-height: 50px; min-height: 50px",
"title": "MaxWell教程"
},
"tbfed-pagefooter": {
"copyright":"Copyright &HACV 2020",
"modify_label": "该文件修订时间:",
"modify_format": "YYYY-MM-DD HH:mm:ss"
},
"code":
{
"copyButtons": false
}
}
}
四、安装插件后serve
观察,它导入了loading plugin
表示导入插件
D:\___MyGitbook\DOS>gitbook serve
Live reload server started on port: 35729
Press CTRL+C to quit ...
info: 7 plugins are installed
info: loading plugin "livereload"... OK
info: loading plugin "highlight"... OK
info: loading plugin "search"... OK
info: loading plugin "lunr"... OK
info: loading plugin "sharing"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-default"... OK
info: found 1 pages
info: found 0 asset files
info: >> generation finished with success in 3.0s !
Starting server ...
Serving book on http://localhost:4000
(node:10216) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
^C终止批处理操作吗(Y/N)?
^C
五、用了NVM后收拾摊子
C:\Users\MaxWell\AppData\Roaming\npm\node_modules
C:\Users\MaxWell>hexo -v
'hexo' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\MaxWell>where hexo
C:\Users\MaxWell\AppData\Roaming\npm\node_modules\hexo-cli\bin\hexo
发现hexo无法使用了,原先的博客也无法使用了,现在该如何进行进行处理?
C:\Users\MaxWell>npm install -g hexo-cli
C:\Program Files\nodejs\hexo -> C:\Program Files\nodejs\node_modules\hexo-cli\bin\hexo
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\hexo-cli\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ hexo-cli@4.2.0
added 63 packages from 324 contributors in 22.143s
C:\Users\MaxWell>hexo -v
hexo-cli: 4.2.0
os: Windows_NT 10.0.16299 win32 x64
node: 12.16.3
v8: 7.8.279.23-node.35
uv: 1.34.2
zlib: 1.2.11
brotli: 1.0.7
ares: 1.16.0
modules: 72
nghttp2: 1.40.0
napi: 5
llhttp: 2.0.4
http_parser: 2.9.3
openssl: 1.1.1g
cldr: 36.0
icu: 65.1
tz: 2019c
unicode: 12.1
C:\Users\MaxWell>node -v
v12.16.3
C:\Users\MaxWell>npm -v
6.14.4
C:\Users\MaxWell>where hexo
C:\Users\MaxWell\AppData\Roaming\npm\node_modules\hexo-cli\bin\hexo
C:\Program Files\nodejs\hexo
C:\Program Files\nodejs\hexo.cmd
重新去测试
D:\___MySoftware\05.MyBlog\__Gitee\HACV>hexo clean && hexo g && hexo s
INFO Deleted database.
INFO Deleted public folder.
Gitbook参考的部分博客
1、(最好的教程)目录初始化 · Gitbook使用入门
2、GitBook 使用教程
3、gitbook如何可以创建多级目录?