第七章 插件

Gitbook 使用插件来进行个性化定制。 GitBook插件官网 https://plugins.gitbook.com/ 上有数百个插件可用

可以在 book.json 文件的 plugins 和 pluginsConfig 字段添加插件及相关配置。

添加插件后要用gitbook install进行插件安装,否则会报如下错误

$ gitbook serve .
Live reload server started on port: 35729
Press CTRL+C to quit ...

info: 7 plugins are installed
info: 6 explicitly listed

Error: Couldn't locate plugins "search-plus", Run 'gitbook install' to install plugins from registry.

安装插件

$ gitbook install ./
info: installing 1 plugins using npm@3.9.2
info:
info: installing plugin "search-plus"
info: install plugin "search-plus" (*) from NPM with version 1.0.3
/Users/william/mygitbook/gitbook
└─┬ gitbook-plugin-search-plus@1.0.3
  └── html-entities@1.2.0

info: >> plugin "search-plus" installed with success

安装插件之后再运行

$ gitbook serve . Live reload server started on port: 35729 Press CTRL+C to quit ...

info: 8 plugins are installed info: 6 explicitly listed info: loading plugin "search-plus"... OK info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 26 pages info: found 1 asset files info: >> generation finished with success in 2.5s !

Starting server ... Serving book on http://localhost:4000

results matching ""

    No results matching ""