相信很多人在学习的时候都会整理出一些笔记,如果这个笔记只需要自己看的话,使用有道云、印象笔记都可以,如果想分享给别人看的话怎么做呢?下面说一下如何使用gitbook快速的在github上构建一个笔记。
如何安装就不细说了,网上有大量的资料,例如 Gitbook 入门教程。下面只说说我构建过程遇到的坑。
关于目录
- SUMMARY.md文件支持使用markdown语法来构建目录 例如
* [leetcode刷题本](leetcode/README.md)
* [数组](leetcode/shu-zu/README.md)
* [55.跳跃游戏](leetcode/shu-zu/jump-game.md)
* [链表](leetcode/lian-biao/README.md)
- 如果要构建分级目录,并且想用文件夹来分类的话,每个文件夹下最好都要有一个README.md文件。并且Summary上的链接最好都是指向具体.md文件,而不是目录的路径。
book.json
- book.json有注释、有空行的话是无法解析的。所以一定要仔细的检查book.json的格式。下面是我的book.json,里面加了几款好用的插件,直接把我的脚本粘贴过去就可以用了。
{
"description":"我的笔记本",
"extension": null,
"generator": "site",
"isbn": "loye-1",
"links": {
"sharing": {
"all": null,
"facebook": null,
"google": null,
"twitter": null,
"weibo": null
},
"sidebar": {}
},
"output": null,
"pdf": {
"fontSize": 12,
"footerTemplate": null,
"headerTemplate": null,
"margin": {
"bottom": 36,
"left": 62,
"right": 62,
"top": 36
},
"pageNumbers": false,
"paperSize": "a4"
},
"plugins": [
"back-to-top-button",
"chapter-fold",
"code",
"pageview-count",
"-lunr",
"-search",
"search-pro",
"hide-element",
"tbfed-pagefooter"
],
"pluginsConfig": {
"hide-element": {
"elements": [".gitbook-link"]
},
"tbfed-pagefooter": {
"copyright":"Copyright © dsx2016.com 2019",
"modify_label": "该文章修订时间:",
"modify_format": "YYYY-MM-DD HH:mm:ss"
}
},
"title": "CY-Note",
"variables": {}
}
关于构建
- 由于github上支持在master、gh-pages、master/docs分支上来搭建静态网站,所以我认为最好的做法是直接将静态网页构建到docs文件夹下,而不是默认的_book文件夹,命令如下
gitbook build ./ ./docs
然后直接推送到master分支,在github-pages那里选择用docs文件来构建网站上就可以了。
IDE
- 建议使用VSCode来写gitbook
最后附上我的笔记zoeyhao.github.io/LY-Note/