|
| 1 | +## 插件 |
| 2 | +记录一些实用的插件 |
| 3 | +### Disqus |
| 4 | +添加disqus评论 |
| 5 | + |
| 6 | +[插件地址](https://plugins.gitbook.com/plugin/disqus) |
| 7 | + ```json |
| 8 | +"plugins": [ |
| 9 | + "disqus" |
| 10 | +], |
| 11 | +"pluginsConfig": { |
| 12 | + "disqus": { |
| 13 | + "shortName": "gitbookuse" |
| 14 | + } |
| 15 | +} |
| 16 | +``` |
| 17 | + |
| 18 | +### Search Pro |
| 19 | +支持中文搜索, 需要将默认的search插件去掉, :worried: 在window下安装该插件时总是出错 :worried: |
| 20 | +[插件地址](https://plugins.gitbook.com/plugin/search-pro) |
| 21 | +```json |
| 22 | +"plugins": [ |
| 23 | + "-search", |
| 24 | + "search-pro" |
| 25 | +], |
| 26 | +"pluginsConfig": { |
| 27 | + "search-pro": { |
| 28 | + "cutWordLib": "nodejieba", |
| 29 | + "defineWord" : ["Gitbook Use"] |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +### Advanced Emoji |
| 35 | +支持emoji表情 |
| 36 | +[emoij表情列表](http://www.emoji-cheat-sheet.com/) |
| 37 | +[插件地址](https://plugins.gitbook.com/plugin/advanced-emoji) |
| 38 | +```json |
| 39 | +"plugins": [ |
| 40 | + "advanced-emoji" |
| 41 | +] |
| 42 | +``` |
| 43 | +使用示例: |
| 44 | +:bowtie: :smile: :laughing: :blush: :smiley: :relaxed: |
| 45 | + |
| 46 | +### Github |
| 47 | +添加github图标 |
| 48 | +[插件地址](https://plugins.gitbook.com/plugin/github) |
| 49 | +```json |
| 50 | +"plugins": [ |
| 51 | + "github" |
| 52 | +], |
| 53 | +"pluginsConfig": { |
| 54 | + "github": { |
| 55 | + "url": "https://github.com/zhangjikai" |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +### Ace Plugin |
| 61 | +使gitbook支持ace |
| 62 | +[插件地址](https://plugins.gitbook.com/plugin/ace) |
| 63 | + |
| 64 | +```json |
| 65 | +"plugins": [ |
| 66 | + "ace" |
| 67 | +] |
| 68 | +``` |
| 69 | +使用示例: |
| 70 | + |
| 71 | +{%ace edit=true, lang='c_cpp'%} |
| 72 | +// This is a hello world program for C. |
| 73 | +#include <stdio.h> |
| 74 | + |
| 75 | +int main(){ |
| 76 | + printf("Hello World!"); |
| 77 | + return 1; |
| 78 | +} |
| 79 | +{%endace%} |
| 80 | + |
| 81 | +### Emphasize |
| 82 | +为文字加上底色 |
| 83 | +[插件地址](https://plugins.gitbook.com/plugin/emphasize) |
| 84 | +```json |
| 85 | +"plugins": [ |
| 86 | + "emphasize" |
| 87 | +] |
| 88 | +``` |
| 89 | +使用示例: |
| 90 | + |
| 91 | +This text is {% em %}highlighted !{% endem %} |
| 92 | + |
| 93 | +This text is {% em %}highlighted with **markdown**!{% endem %} |
| 94 | + |
| 95 | +This text is {% em type="green" %}highlighted in green!{% endem %} |
| 96 | + |
| 97 | +This text is {% em type="red" %}highlighted in red!{% endem %} |
| 98 | + |
| 99 | +This text is {% em color="#ff0000" %}highlighted with a custom color!{% endem %} |
| 100 | + |
| 101 | +### KaTex |
| 102 | +为了支持数学公式, 我们可以使用`KaTex`和`MathJax`插件, 官网上说`Katex`速度要快于`MathJax` |
| 103 | +[插件地址](https://plugins.gitbook.com/plugin/katex) |
| 104 | +[MathJax使用LaTeX语法编写数学公式教程](http://iori.sinaapp.com/17.html) |
| 105 | +```json |
| 106 | +"plugins": [ |
| 107 | + "katex" |
| 108 | +] |
| 109 | +``` |
| 110 | +使用示例: |
| 111 | + |
| 112 | +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 %} |
| 113 | + |
| 114 | +$$ |
| 115 | +\int_{-\infty}^\infty g(x) dx |
| 116 | +$$ |
| 117 | + |
| 118 | +$$ |
| 119 | +1 \over 3 |
| 120 | +$$ |
| 121 | + |
| 122 | +### Include Codeblock |
| 123 | +使用代码块的格式显示所包含文件的内容. 该文件必须存在. |
| 124 | +[插件地址](https://plugins.gitbook.com/plugin/include-codeblock) |
| 125 | +```json |
| 126 | +"plugins": [ |
| 127 | + "include-codeblock" |
| 128 | +] |
| 129 | +``` |
| 130 | +使用示例: |
| 131 | + |
| 132 | +[import](styles/website.css) |
| 133 | + |
| 134 | +### Splitter |
| 135 | +使侧边栏的宽度可以自由调节 |
| 136 | + |
| 137 | +[插件地址](https://plugins.gitbook.com/plugin/splitter) |
| 138 | +```json |
| 139 | +"plugins": [ |
| 140 | + "splitter" |
| 141 | +] |
| 142 | +``` |
| 143 | + |
| 144 | +### Mermaid |
| 145 | +支持渲染[Mermaid](https://github.com/knsv/mermaid)图表 |
| 146 | +[插件地址](https://plugins.gitbook.com/plugin/mermaid) |
| 147 | +```json |
| 148 | +"plugins": [ |
| 149 | + "mermaid" |
| 150 | +] |
| 151 | +``` |
| 152 | +使用示例: |
| 153 | +{% mermaid %} |
| 154 | +graph TD; |
| 155 | + A-->B; |
| 156 | + A-->C; |
| 157 | + B-->D; |
| 158 | + C-->D; |
| 159 | +{% endmermaid %} |
| 160 | + |
| 161 | +### Sharing |
| 162 | +分享当前页面, gitbook的默认插件, 使用下面方式来禁用 |
| 163 | +```json |
| 164 | + plugins: ["-sharing"] |
| 165 | +``` |
| 166 | +配置: |
| 167 | + |
| 168 | +```json |
| 169 | +"pluginsConfig": { |
| 170 | + "sharing": { |
| 171 | + "weibo": true, |
| 172 | + "facebook": true, |
| 173 | + "twitter": true, |
| 174 | + "google": false, |
| 175 | + "instapaper": false, |
| 176 | + "vk": false, |
| 177 | + "all": [ |
| 178 | + "facebook", "google", "twitter", |
| 179 | + "weibo", "instapaper" |
| 180 | + ] |
| 181 | + } |
| 182 | +} |
| 183 | +``` |
| 184 | + |
| 185 | +### Tbfed-pagefooter |
| 186 | +为页面添加页脚 |
| 187 | +[插件地址](https://plugins.gitbook.com/plugin/tbfed-pagefooter) |
| 188 | +```json |
| 189 | +"plugins": [ |
| 190 | + "tbfed-pagefooter" |
| 191 | +], |
| 192 | +"pluginsConfig": { |
| 193 | + "tbfed-pagefooter": { |
| 194 | + "copyright":"Copyright © zhangjikai.com 2015", |
| 195 | + "modify_label": "该文件修订时间:", |
| 196 | + "modify_format": "YYYY-MM-DD HH:mm:ss" |
| 197 | + } |
| 198 | +} |
| 199 | + |
| 200 | +``` |
| 201 | + |
| 202 | +### Toggle Chapters |
| 203 | +是左侧的章节目录可以折叠 |
| 204 | +[插件地址](https://plugins.gitbook.com/plugin/toggle-chapters) |
| 205 | +```json |
| 206 | +"plugins": ["toggle-chapters"] |
| 207 | +``` |
| 208 | + |
| 209 | + |
| 210 | +### Sectionx |
| 211 | +将页面分块显示 |
| 212 | +[插件地址](https://plugins.gitbook.com/plugin/sectionx) |
| 213 | +```json |
| 214 | +"plugins": [ |
| 215 | + "sectionx" |
| 216 | +] |
| 217 | +``` |
| 218 | +使用示例 |
| 219 | + |
| 220 | +<!--sec data-title="Sectionx Demo" data-id="section0" data-show=true ces--> |
| 221 | + |
| 222 | +Insert markdown content here (you should start with h3 if you use heading). |
| 223 | +本段代码 |
| 224 | +```md |
| 225 | +<!--sec data-title="Introduction" data-id="section0" data-show=true ces--> |
| 226 | +Insert markdown content here (you should start with h3 if you use heading). |
| 227 | +<!--endsec-->` |
| 228 | + |
| 229 | +``` |
| 230 | + |
| 231 | +<!--endsec--> |
| 232 | + |
| 233 | +### Codeblock-filename |
| 234 | +为代码块添加文件名称 |
| 235 | +[插件地址](https://plugins.gitbook.com/plugin/codeblock-filename) |
| 236 | +```json |
| 237 | +plugins: [ "codeblock-filename" ] |
| 238 | +``` |
| 239 | +使用示例: |
| 240 | +```:helloworld |
| 241 | +helloworld |
| 242 | +``` |
| 243 | +```js:test.js |
| 244 | +console.log("test"); |
| 245 | +``` |
| 246 | +### ga |
| 247 | +google 统计 |
| 248 | +[插件地址](https://plugins.gitbook.com/plugin/ga) |
| 249 | +```json |
| 250 | +"plugins": [ |
| 251 | + "ga" |
| 252 | + ], |
| 253 | +"pluginsConfig": { |
| 254 | + "ga": { |
| 255 | + "token": "UA-XXXX-Y" |
| 256 | + } |
| 257 | +} |
| 258 | +``` |
| 259 | + |
| 260 | +### baidu |
| 261 | +百度统计 |
| 262 | +[插件地址](https://plugins.gitbook.com/plugin/baidu) |
| 263 | +```json |
| 264 | +"plugin": [ |
| 265 | + "baidu" |
| 266 | + ], |
| 267 | +"pluginsConfig": { |
| 268 | + "baidu": { |
| 269 | + "token": "YOUR TOKEN" |
| 270 | + } |
| 271 | +} |
| 272 | +``` |
| 273 | + |
| 274 | + |
| 275 | + |
| 276 | + |
| 277 | + |
0 commit comments