Typora: 跨平台的markdown编辑器 GitBook: 基于 Node.js,所以我们首先需要安装 Node.js,然后安装gitbook-cli
部署环境
nodeenv envnode
# 创建环境
. envnode/bin/activate
# 切换到当前虚拟环境
npm config set registry=http://registry.npm.taobao.org -g
npm install -g gitbook-cli
# 更换国内源,并安装gitbook
gitbook serve
# 查看 http://localhost:4000
创建文档工作区
mkdir ~/Desktop/mybook
gitbook init
# 初始化
gitbook serve --port 12345
# 指定端口运行服务
gitbook serve 命令,然后在浏览器地址栏中输入 http://localhost:4000 便可预览书籍。
Typora编辑文档
安装插件
book.json
{
"title": "Mybook",
"author": "LJ",
"description": "markdown笔记",
"language": "zh-hans",
"plugins": [
"-lunr",
"-search",
"search-pro",
"-highlight",
"prism",
"expandable-chapters",
"chapter-fold",
"back-to-top-button",
"splitter",
"-simple-page-toc",
"page-toc-button",
"tbfed-pagefooter",
"-fontsettings"
],
"styles": {
"website": "styles/website.css"
},
"pluginsConfig": {
"prism": {
"css": ["prismjs/themes/prism-tomorrow.css"]
},
"tbfed-pagefooter": {
"copyright": "Copyright © 2020",
"modify_label": "该文件编辑时间:",
"modify_format": "YYYY-MM-DD HH:mm:ss"
},
"page-toc-button": {
"maxTocDepth": 3,
"minTocSize": 2
}
}
}
gitbook install
# 安装插件
使用插件
click-reveal 点击显示/隐藏代码
"plugins": [
"click-reveal"
]
Quick use :
{% reveal %}
Your element to **hide**
{% endreveal %}
With custom text :
{% reveal text="Click here to reveal my secret" %}
Your element to **hide**
{% endreveal %}
tbfed-pagefooter 页面添加页脚
{
"plugins": [
"tbfed-pagefooter"
],
"pluginsConfig": {
"tbfed-pagefooter": {
"copyright":"Copyright © xxxx.com 2017",
"modify_label": "该文件修订时间:",
"modify_format": "YYYY-MM-DD HH:mm:ss"
}
}
}
如果想加入一个URL,自己可以去index.js里,把powered by gitbook,改成 powered by <a href="你的URL" target="_blank">你的名字</a>
互联网部署
setsid gitbook serve .
# 后台运行
nginx
server {
listen 80;
server_name book.opsbase.cn;
location / {
proxy_pass http://localhost:4000;
proxy_set_header Host $host;
proxy_buffering off;
}
}
来源:oschina
链接:https://my.oschina.net/attacker/blog/4278135