记录一些实用的插件
添加disqus评论
"plugins": [
"disqus"
],
"pluginsConfig": {
"disqus": {
"shortName": "gitbookuse"
}
}
支持中文搜索, 需要将默认的search插件去掉, 😟 在window下安装该插件时总是出错, 同时如果标题中有包含的关键字, 标题的样式会有所变化 😟
插件地址
"plugins": [
"-search",
"search-pro"
],
"pluginsConfig": {
"search-pro": {
"cutWordLib": "nodejieba",
"defineWord" : ["Gitbook Use"]
}
}
"plugins": [
"advanced-emoji"
]
使用示例:
😄 😆 😊 😃
添加github图标
插件地址
"plugins": [
"github"
],
"pluginsConfig": {
"github": {
"url": "https://github.com/zhangjikai"
}
}
使gitbook支持ace
插件地址
"plugins": [
"ace"
]
使用示例:
{%ace edit=true, lang='c_cpp'%} // This is a hello world program for C. #include <stdio.h>
int main(){ printf("Hello World!"); return 1; } {%endace%}
为文字加上底色
插件地址
"plugins": [
"emphasize"
]
使用示例:
This text is {% em %}highlighted !{% endem %}
This text is {% em %}highlighted with markdown!{% endem %}
This text is {% em type="green" %}highlighted in green!{% endem %}
This text is {% em type="red" %}highlighted in red!{% endem %}
This text is {% em color="#ff0000" %}highlighted with a custom color!{% endem %}
为了支持数学公式, 我们可以使用KaTex
和MathJax
插件, 官网上说Katex
速度要快于MathJax
插件地址
MathJax使用LaTeX语法编写数学公式教程
"plugins": [
"katex"
]
使用示例:
When {% math %}a \ne 0{% endmath %}, there are two solutions to {% math %}(ax^2 + bx + c = 0){% endmath %} and they are {% math %}x = {-b \pm \sqrt{b^2-4ac} \over 2a}.{% endmath %}
使用代码块的格式显示所包含文件的内容. 该文件必须存在.
插件地址
"plugins": [
"include-codeblock"
]
使用示例:
使侧边栏的宽度可以自由调节
插件地址
"plugins": [
"splitter"
]
"plugins": [
"mermaid"
]
使用示例: {% mermaid %} graph TD; A-->B; A-->C; B-->D; C-->D; {% endmermaid %}
分享当前页面, gitbook的默认插件, 使用下面方式来禁用
plugins: ["-sharing"]
配置:
"pluginsConfig": {
"sharing": {
"weibo": true,
"facebook": true,
"twitter": true,
"google": false,
"instapaper": false,
"vk": false,
"all": [
"facebook", "google", "twitter",
"weibo", "instapaper"
]
}
}
为页面添加页脚
插件地址
"plugins": [
"tbfed-pagefooter"
],
"pluginsConfig": {
"tbfed-pagefooter": {
"copyright":"Copyright © zhangjikai.com 2015",
"modify_label": "该文件修订时间:",
"modify_format": "YYYY-MM-DD HH:mm:ss"
}
}
是左侧的章节目录可以折叠
插件地址
"plugins": ["toggle-chapters"]
将页面分块显示
插件地址
"plugins": [
"sectionx"
]
使用示例
Insert markdown content here (you should start with h3 if you use heading).
本段代码
<!--sec data-title="Introduction" data-id="section0" data-show=true ces-->
Insert markdown content here (you should start with h3 if you use heading).
<!--endsec-->`
为代码块添加文件名称
插件地址
plugins: [ "codeblock-filename" ]
使用示例:
helloworld
console.log("test");
google 统计
插件地址
"plugins": [
"ga"
],
"pluginsConfig": {
"ga": {
"token": "UA-XXXX-Y"
}
}
百度统计
插件地址
"plugin": [
"baidu"
],
"pluginsConfig": {
"baidu": {
"token": "YOUR TOKEN"
}
}