Gitbook在Docker中安装插件的方法

别光在那百度,什么先book.json添加plugin,然后在install?
哥,你现在用的是docker哎,docker都启动不了,你如何gitbook install呢?
乖乖听我的,按我的方法来!

1. docker中使用npm安装插件

[root@it gitbook]# docker exec gitbook npm install gitbook-plugin-back-to-top-button
npm info it worked if it ends with ok
npm info using npm@3.10.3 npm info using node@v6.3.0 npm info attempt registry request try #1 at 8:09:11 AM
npm http request GET https://registry.npmjs.org/gitbook-plugin-back-to-top-button
npm http 304 https://registry.npmjs.org/gitbook-plugin-back-to-top-button
npm info addNameTag [ 'gitbook-plugin-back-to-top-button', 'latest' ]
npm info lifecycle gitbook-plugin-back-to-top-button@0.1.4~preinstall: gitbook-plugin-back-to-top-button@0.1.4 npm info linkStuff gitbook-plugin-back-to-top-button@0.1.4 npm info lifecycle gitbook-plugin-back-to-top-button@0.1.4~install: gitbook-plugin-back-to-top-button@0.1.4 npm info lifecycle gitbook-plugin-back-to-top-button@0.1.4~postinstall: gitbook-plugin-back-to-top-button@0.1.4
/srv/gitbook
`-- gitbook-plugin-back-to-top-button@0.1.4 npm WARN enoent ENOENT: no such file or directory, open '/srv/gitbook/package.json' npm WARN gitbook No description
npm WARN gitbook No repository field.
npm WARN gitbook No README data
npm WARN gitbook No license field.
npm info ok

ps:进入docker,有两种方式,
一种是:
docker exec -it 54dca0894540 sh
另一种是:
docker exec gitbook gitbook –V
第一种方式,是进入docker容器里面 ,第二种方式,是在外面直接exec容器里的东东。
第一种方式,用containner-id, 第二种方式,用names

[root@it gitbook]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
54dca0894540 fellah/gitbook "/bin/sh -c '/usr/lo…" 2 hours ago Up 8 minutes 0.0.0.0:4000-4000/tcp, :::4000-4000/tcp, 35729/tcp gitbook

2. book.json中,加入plugin内容

{
 "language" : "zh-hans", "plugins": [ "back-to-top-button" ]
}

3. docker ps,看一下进程是否在,不在立马docker logs 看报错信息

[root@it gitbook]# docker logs gitbook
...
Restart after change in file node_modules/gitbook-plugin-back-to-top-button/README.md

Stopping server info: 8 plugins are installed info: loading plugin "back-to-top-button"... OK info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 1 pages info: found 0 asset files info:  generation finished with success in 0.9s ! Starting server ...
Serving book on [http:](http://localhost:4000)//localhost:4000

PS

插件么,网上一堆的,按照需要去下载安装即可,谨记以上的操作步骤,gitbook路上不迷路~~~

以下为我的book.json (需要自建)

{ "language" : "zh-hans", "plugins": [ "back-to-top-button", "chapter-fold", "-lunr", "-search", "search-pro", "splitter" ], "styles": { "website": "styles/website.css" }
}

我的/styles/website.css

.gitbook-link {
         display: none !important;
        }
h1 , h2{
    border-bottom: 1px solid #EFEAEA;
}
posted @ 2021-06-03 16:17  李济宏(Amadeus)  阅读(236)  评论(0编辑  收藏  举报