gitbook.svg

相关网站

 

简介

GitBook 是一种基于 Markdown 和 Git 的文档撰写和托管平台,它提供了一种简单的方式,用 Markdown 语言来写作,并将作品转换成电子书或者文档网站,方便阅读和分享。

GitBook 的优点在于其易用性、灵活性和可定制性,适用于各种文档编写和托管需求,例如技术文档、手册、文档网站等。下面是 GitBook 的一些特点:

  • Markdown 支持:GitBook 使用 Markdown 作为文档撰写语言,支持 Markdown 所有的语法和扩展,使得文档编写变得简单、轻松和高效。
  • 版本控制:GitBook 基于 Git 版本控制系统构建,可以使用 Git 来管理文档的版本,以及进行协作编辑和审核。
  • 多种输出格式:GitBook 支持将文档导出为多种格式,包括 PDF、ePub 和 mobi 等电子书格式,以及网站的形式。
  • 插件支持:GitBook 允许用户根据自己的需求添加额外的功能,包括主题定制、插件扩展、搜索引擎优化等。
  • 部署方便:GitBook 可以将文档部署到多种静态站点托管服务上,例如 GitHub Pages、Netlify 和 Heroku 等。

GitBook 适用于个人文档的撰写和管理,也适用于团队的协作和文档管理。

GitBook.com 是一个围绕 GitBook 发行书籍的社区,提供免费和付费的服务,免费账户就可以享受诸多服务,包括:

  • 1 本私有书籍
  • 托管不限数量的公开书籍
  • 售卖不限数量的书籍,并分享 80% 的书籍收入
  • 不限数量的协作者
  • 免费的在线书籍编辑器

对于普通用户来说,免费账号已经足够使用,虽然限制为 1 本私有书籍,但没有限制书籍的大小,非常适合个人的学习笔记。

安装

安装 GitBook 可以分为两种方式:全局安装和本地安装。

全局安装 GitBook

  1. 安装 Node.js

    • 首先需要安装 Node.js,可以在 Node.js 官网上下载适合自己操作系统的版本进行安装。Node.js 版本在 10.x 版本不会报错,其他版本可能会报错。

    • 在 Windows 操作系统中,要将 Node.js 添加到系统环境变量中,可以按照以下步骤进行:

      1. 打开“开始菜单”,搜索“环境变量”,选择“编辑系统环境变量”选项。
      2. 在“系统属性”窗口中,选择“高级”选项卡,并点击“环境变量”按钮。
      3. 在“环境变量”窗口中,找到“系统变量”区域,选择“Path”变量,并点击“编辑”按钮。
      4. 在“编辑环境变量”窗口中,点击“新建”按钮,并输入 Node.js 的安装路径(例如:C:\Program Files\nodejs)。
      5. 点击“确定”按钮保存修改,然后关闭所有窗口。
    • 添加完成后,可以在命令行终端中使用 Node.js 的命令和模块了。可以运行以下命令验证 Node.js 是否安装成功:

    1
    node -v

    如果输出了 Node.js 的版本号,则说明 Node.js 安装成功。

  2. 安装 GitBook

    • 打开命令行终端,运行以下命令来安装 GitBook:
    1
    npm install gitbook-cli -g

    这个命令会安装 GitBook 的命令行工具 gitbook-cli,并将其安装到系统全局路径中。

  3. 验证安装

    • 安装完成后,可以运行以下命令验证 GitBook 是否安装成功:
    1
    gitbook --version

    如果显示 GitBook 的版本号,则说明 GitBook 安装成功。

本地安装 GitBook

  1. 安装 Node.js:同全局安装步骤。

  2. 在项目目录下安装 GitBook

    • 打开命令行终端,进入到项目目录下,运行以下命令来安装 GitBook:
    1
    npm install gitbook-cli --save-dev

    这个命令会将 GitBook 安装到项目目录下的 node_modules 目录中,并将其作为项目的开发依赖保存在 package.json 文件中。

  3. 验证安装

    • 安装完成后,可以运行以下命令验证 GitBook 是否安装成功:
    1
    ./node_modules/.bin/gitbook --version

    如果显示 GitBook 的版本号,则说明 GitBook 安装成功。

安装完成后,可以使用 GitBook 来创建新的文档、编写和编辑文档,并将其导出为电子书或文档网站的形式。可以参考 GitBook 的官方文档来学习如何使用 GitBook:GitBook 官方文档

使用

GitBook 的基本用法非常简单,基本上就只有两步:

  1. 使用 gitbook init 初始化书籍目录
  2. 使用 gitbook serve 编译书籍

下面将结合一个非常简单的实例,来介绍 GitBook 的基本用法。

gitbook init

首先,创建如下目录结构:

1
2
3
4
5
$ tree book/
book/
├── README.md
└── SUMMARY.md
0 directories, 2 files

README.mdSUMMARY.md 是两个必须文件,README.md 是对书籍的简单介绍:

1
2
3
markdown复制代码# README

This is a book powered by [GitBook](https://github.com/GitbookIO/gitbook).

SUMMARY.md 是书籍的目录结构,内容如下:

1
2
3
4
5
6
markdown复制代码# SUMMARY

* [Chapter1](chapter1/README.md)
* [Section1.1](chapter1/section1.1.md)
* [Section1.2](chapter1/section1.2.md)
* [Chapter2](chapter2/README.md)

创建了这两个文件后,使用 gitbook init,它会为我们创建 SUMMARY.md 中的目录结构。

1
2
3
4
5
6
7
8
9
10
11
12
13
bash复制代码$ cd book
$ gitbook init
$ tree
.
├── README.md
├── SUMMARY.md
├── chapter1
│ ├── README.md
│ ├── section1.1.md
│ └── section1.2.md
└── chapter2
└── README.md
2 directories, 6 files

注意:gitbook init 只支持两级目录!

gitbook serve

书籍目录结构创建完成以后,就可以使用 gitbook serve 来编译和预览书籍了:

1
2
3
4
5
6
7
bash复制代码$ gitbook serve
Press CTRL+C to quit ...
Live reload server started on port: 35729
Starting build ...
Successfully built!
Starting server ...
Serving book on http://localhost:4000

gitbook serve 命令实际上会首先调用 gitbook build 编译书籍,完成以后会打开一个 web 服务器,监听在本地的 4000 端口。

现在,可以用浏览器打开 http://127.0.0.1:4000 查看书籍的效果,如下图所示:

(这里可以插入预览图)

GitBook 为我们创建了书籍目录结构后,就可以向其中添加真正的内容了。文件的编写使用 Markdown 语法,在文件修改过程中,每一次保存文件,gitbook serve 都会自动重新编译,所以可以持续通过浏览器来查看最新的书籍效果!

发布

部署到 GitHub

将编译好的 _book 文件内容直接推送到 GitHub 仓库。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
bash复制代码# 初始化 Git 仓库
$ git init

# 添加远程仓库
$ git remote add origin <你的 GitHub 仓库地址>

# 添加所有文件
$ git add .

# 提交更改
$ git commit -m "Initial commit"

# 推送到远程仓库
$ git push -u origin master

完成上述步骤后,书籍就会部署到 GitHub 上了,可以通过 GitHub Pages 进行访问

常用插件


安装插件命令:

1
gitbook init

book.js文件需要放在gitbook项目目录中

常用插件列表

插件名 安装命令 功能
accordion npm i gitbook-plugin-accordion 手风琴-折叠内容段落
hide-element(插件没有效果) npm i gitbook-plugin-hide-element 隐藏类名
code npm i gitbook-plugin-code-fox GitBook 的代码插件
sharing npm i gitbook-plugin-sharing 共享按钮
sharing-plus npm i gitbook-plugin-sharing-plus 一个强大的 GitBook 搜索插件
donate npm i gitbook-plugin-donate Gitbook 捐赠打赏插件
anchor-navigation-ex npm i gitbook-plugin-anchor-navigation-ex 锚点-导航插件
expandable-chapters npm i gitbook-plugin-expandable-chapters 为每个章节添加一个图标
sidebar-style npm i gitbook-plugin-sidebar-style 侧边栏样式
splitter npm i gitbook-plugin-splitter 该插件提供了一个垂直条来划分摘要和主要内容
emphasize npm i gitbook-plugin-emphasize 强调并突出显示内容的特定部分
edit-link npm i gitbook-plugin-edit-link 在每个页面上添加了“编辑此页面”链接
github npm i gitbook-plugin-github 在右上角添加github图标
lightbox npm i gitbook-plugin-lightbox 点击图片弹窗显示
youtube npm i gitbook-plugin-youtube 插入YouTube视频
copyright npm i gitbook-plugin-copyright 版权保护插件
tbfed-pagefooter npm i gitbook-plugin-tbfed-pagefooter 版权信息插件
pageview-count npm i gitbook-plugin-pageview-count 文档页面阅读数插件

accordion

Example

https://artalar.github.io/gitbook-plugin-accordion/

Usage

In GitBook editor (or any else):

1
2
3
%accordion%Some title here%accordion%
Any content here
%/accordion%

that`s all! But each tag should be in one paragraph
similarly you can include accordion in accordion (like content)
IE11+ (flexboxes)
573 B minified, 282 B minified + gzipped

Install

1
2
3
4
5
6
Update `book.json`, like:
{
"gitbook": "3.2.2",
"title": "Cool book",
"plugins": \["accordion"\]
}

Then run

1
gibook install 

That`s all, see Usage

hide-element

插件没有效果

隐藏您不想看到的元素。

book.json的plugins参数中添加插件名和配置信息:

1
2
3
4
5
6
7
8
9
10
{
"plugins": \[
"hide-element"
\],
"pluginsConfig": {
"hide-element": {
"elements": \[".gitbook-link"\]
}
}
}

上面的配置信息中设置了隐藏的类名,所以Published by GitBook本书使用 GitBook 发布 就看不见了。

以下为可用方法:

%accordion%隐藏删除 gitbook Published with GitBook 的方法%accordion%

说明

用GitBook生成的网页中,在左侧目录下方默认有一个Published with GitBook连接,可以将这个连接去掉,或者替换成其它连接。

方法

在gitbook站点目录创建_layouts->website->summary.html

隐藏删除 gitbook Published with GitBook 的方法

隐藏删除 gitbook Published with GitBook 的方法

在summary.html中填写下面内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{% macro articles(\_articles) %}
{% for article in \_articles %}
<li class="chapter {% if article.path == file.path and not article.anchor %}active{% endif %}" data-level="{{ article.level }}" {% if article.path %}data-path="{{ article.pathresolveFile }}"{% endif %}>
{% if article.path and getPageByPath(article.path) %}
<a href="{{ article.pathresolveFile }}{{ article.anchor }}">
{% elif article.url %}
<a target="\_blank" href="{{ article.url }}">
{% else %}
<span>
{% endif %}
{% if article.level != "0" and config.pluginsConfig\['theme-default'\].showLevel %}
<b>{{ article.level }}.</b>
{% endif %}
{{ article.title }}
{% if article.path or article.url %}
</a>
{% else %}
</span>
{% endif %}
{% if article.articles.length > 0 %}
<ul class="articles">
{{ articles(article.articles, file, config) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
<ul class="summary">
{% set \_divider = false %}
{% if config.links.sidebar %}
{% for linkTitle, link in config.links.sidebar %}
{% set \_divider = true %}
<li>
<a href="{{ link }}" target="\_blank" class="custom-link">{{ linkTitle }}</a>
</li>
{% endfor %}
{% endif %}
{% if \_divider %}
<li class="divider"></li>
{% endif %}
{% for part in summary.parts %}
{% if part.title %}
<li class="header">{{ part.title }}</li>
{% elif not loop.first %}
<li class="divider"></li>
{% endif %}
{{ articles(part.articles, file, config) }}
{% endfor %}
<li class="divider"></li>
<!--<li>-->
<!--<a href="https://www.gitbook.com" target="blank" class="gitbook-link">-->
<!--{{ "GITBOOK\_LINK"t }}-->
<!--</a>-->
<!--</li>-->
</ul>

重启gitbook serve即可,下面是效果

隐藏删除 gitbook Published with GitBook 的方法

%/accordion%

code

GitBook 的代码插件

代码块很酷,但还可以更酷。该插件添加了多行块的行号和复制按钮以轻松复制块的内容。

太酷了,我可以看到它工作吗?

下图显示了单行代码块:

单线

当显示多行代码时,会添加行号:

多线

我该如何使用这个插件?

您只需编辑 book.json 并修改它,添加如下内容:

1
"plugins" : \[ "code" \],

这将为您设置好一切。如果您想摆脱复制按钮,请也添加此部分:

1
2
3
4
5
"pluginsConfig": {
"code": {
"copyButtons": false
}
}

sharing

该插件在 GitBook 网站工具栏中添加了共享按钮,用于在社交网络上共享书籍。

禁用此插件

这是一个默认插件,可以使用配置禁用它book.json

1
2
3
{
plugins: \["-sharing"\]
}

配置

该插件可以在以下位置配置book.json

默认配置是:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"pluginsConfig": {
"sharing": {
"facebook": true,
"twitter": true,
"google": false,
"weibo": false,
"instapaper": false,
"vk": false,
"all": \[
"facebook", "google", "twitter",
"weibo", "instapaper"
\]
}
}
}

sharing-plus

一个强大的 GitBook 搜索插件。

特征

* Search any character
* Search across element (for search code)
* Remember search url

使用这个插件

在使用此插件之前,您应该先禁用默认的搜索插件,这是一个book.json配置示例:

1
2
3
{
plugins: \["-lunr", "-search", "search-plus"\]
}

注意:仅 gitbook >= 3.0.0 支持

例子

img img img

打开https://lwdgit.github.io/gitbook-plugin-search-plus/或者自己测试一下

git clone git@github.com:lwdgit/gitbook-plugin-search-plus.git -b gh-pages
cd gitbook-plugin-search-plus
npm install
npm start
然后打开http://127.0.0.1:4000

Config:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"plugins": \["donate"\],
"pluginsConfig": {
"donate": {
"wechat": "例:/images/qr.png",
"alipay": "http://blog.willin.wang/static/images/qr.png",
"title": "默认空",
"button": "默认值:Donate",
"alipayText": "默认值:支付宝捐赠",
"wechatText": "默认值:微信捐赠"
}
}
}

演示:http://money.js.cool/

如果喜欢,请打赏

anchor-navigation-ex

❗ 插件配置不兼容V1. X版本如下

😘 我的英文不好,这个文档是通过机器翻译的,如果你不明白,请阅读中文文档,翻译本身

插件功能

  • H1-H6给页面标题增加锚点效果
  • 浮动导航模式
  • 页面顶部导航模式
  • 图标层次显示前的导航标题,H1、H3级别图标的自定义
  • plugins[“theme-default”],页面标题级别与默认主题官方showLevel层次结构关联
  • plugins[“theme-default”],插件风格网站默认主题三种风格:White、Sepia、Night
  • <extoc></extoc>向页面添加标签会在此处生成 TOC 目录
  • 将标签添加<! - ex_nonav ->到页面,而不在该页面上生成浮动导航
  • config.printLog=true,打印过程当前进度,调试很有用
  • config.multipleH1=false,去掉丑陋的冗余1.序列号(比如你的书后面跟随一个只有一个H1标签的MD文件)
  • config.showGoTop=true,显示返回顶部按钮 V1.0.11+
  • config.float.floatIcon ,可以配置浮动导航浮动图标样式 V1.0.12+
  • <!-- ex_nolevel -->页面 添加标签,该页面不生成分层编号 V1.0.12+

插件效果

如何使用插件?

在您的book. Json添加插件中:

1
2
3
4
5
{
"plugins": \[
"anchor-navigation-ex"
\]
}

然后安装插件:

1
gitbook install ./

可以使用的插件详细配置请点击这里查看

或者安装单独的插件

1
npm install gitbook-plugin-anchor-navigation-ex --save

打开 npm :https://www.npmjs.com/package/gitbook-plugin-anchor-navigation-ex

这设置了以下插件功能,并重写。

  1. https://github.com/zhangzq/gitbook-plugin-navigator
  2. https://github.com/yaneryou/gitbook-plugin-anchor-navigation

expandable-chapters

该插件为每个章节添加一个图标,该图标有一个子级和用于子级列表折叠/展开的 css 状态。

如何使用它?

将其添加到您的book.json配置中:

1
2
3
{
plugins: \["collapsible-chapters"\]
}

使用以下命令安装插件:

1
gitbook install

配置

暂时不需要配置,可以留空。

1
2
3
4
5
{
"pluginsConfig": {
"collapsible-chapters":{}
}
}

也可以看看

也许您会发现https://github.com/poojan/gitbook-plugin-toggle-chapters也很有用?

1
2
3
4
5
6
7
8
9
10
11
Config:

{
"plugins": \["sidebar-style"\],
"pluginsConfig": {
"sidebar-style": {
"title": "书题",
"author": "作者"
}
}
}

如果 author 字段设置为空字符串,将不会显示作者信息

splitter

分离器

该插件提供了一个垂直条来划分摘要和主要内容。

国家公共管理

其他功能

  • 它将把分离器的位置信息保存到sessionStorage中。

如何使用它?

将其添加到您的book.json配置中:

1
2
3
{
“插件” :\[ “分割器” \]
}

使用以下命令安装插件:

1
gitbook init

变更日志

版本 0.0.6 (2016-12-06T16:54:38)

  • 修复:修复当屏幕尺寸的宽度为 600px 或更小时不执行任何操作 (#6)
  • 修复:将栏位置从“localStorage”更改为“sessiongStorage”(#10)

版本 0.0.6 (2015-11-06T16:54:38)

  • 支持的 Gitbook v3

版本 0.0.5 (2015-11-06T16:54:38)

  • 修复了 Gitbook V2.5.x 中摘要视图显示的切换按钮不起作用的问题

该软件根据 MIT 许可证发布,请参阅 LICENSE.txt。

emphasize

强调 GitBook 中的文本

强调并突出显示内容的特定部分

如何使用它?

在您的中配置插件book.json

1
2
3
{
“插件”:\[ “强调” \]
}

然后在您的 markdown/asciidoc 内容中,使用以下命令突出显示一些文本:

1
2
3
4
5
此文本已{% em %}突出显示!{% endem %}
此文本{% em %}用 \*\*markdown\*\* 突出显示!{% endem %}
此文本{% em type="green" %}以绿色突出显示!{% endem %}
此文本{% em type="red" %}以红色突出显示!{% endem %}
此文本{% em color="#ff0000" %}使用自定义颜色突出显示!{% endem %}

这个 GitBook 插件在每个页面上添加了“编辑此页面”链接。

链接目标将是 Github 或 Gitlab 或任何存储库上该页面的源文件。

截屏

gitbook-插件-编辑-链接

用法

步骤1 - 更新book.json文件

在你的 gitbookbook.json文件中,添加edit-linkplugins列表中。

在 中pluginsConfig,设置base值,该值是 github 或 gitlab 或其他代码存储库的基本路径。尾部斜杠不是必需的。

默认情况下,链接标签为“编辑此页面”。您可以使用插件配置更改它label

book.jsongitbook 2.0.1 及以上版本的示例文件

1
2
3
4
5
6
7
8
9
10
{
"gitbook": "2.0.1",
"plugins": \["edit-link"\],
"pluginsConfig": {
"edit-link": {
"base": "https://github.com/USER/REPO/edit/BRANCH/path/to/book",
"label": "Edit This Page"
}
}
}
book.jsongitbook 版本 2.0.1+ 和多语言标签的示例文件
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"gitbook": "2.0.1",
"plugins": \["edit-link"\],
"pluginsConfig": {
"edit-link": {
"base": "https://github.com/USER/REPO/edit/BRANCH/path/to/book",
"label": {
"en": "Edit This Page",
"de": "Seite bearbeiten"
}
}
}
}
book.json旧版 gitbook 版本 <= 1.5.0 的示例文件
1
2
3
4
5
6
7
8
9
10
{
"gitbook": "1.5.0",
"plugins": \["edit-link@1.1.0"\],
"pluginsConfig": {
"edit-link": {
"base": "https://github.com/USER/REPO/edit/BRANCH/path/to/book",
"label": "Edit This Page"
}
}
}

注意book.json:如果您的书还没有,上面的代码片段可以用作完整文件。

Github/Gitlab:在 string 中,如果您希望源文件以读取模式打开,而不是直接在 github/gitlab 上以编辑模式打开,则...REPO/edit/BRANCH...可以替换edit为。tree

步骤#2 - gitbook 命令

跑步gitbook install。它会自动为你的书安装edit-linkgitbook 插件。这只需要一次。

照常制作您的书 ( gitbook build) 或服务 ( )。gitbook serve

故障排除

  1. 如果您没有看到“编辑此页面”链接,请检查您的链接是否book.json有效。您可以使用这个在线工具 - http://json.parser.online.fr/beta/
  2. 检查您是否使用默认的 gitbook 主题。不建议直接修改gitbook主题。

已知问题

Gitbook 2.0.1 删除了page:after该插件所需的钩子。这里报告了一个问题 - https://github.com/GitbookIO/gitbook/issues/724但同时该插件正在使用此拉取请求添加的解决方法 - https://github.com/rtCamp/gitbook-plugin-edit -链接/拉/4

因此,当使用 Gitbook 2.0.1 时,您可能会在运行构建时在控制台中看到以下警告:

警告:插件“gitbook-plugin-edit-link”使用的挂钩“page”已弃用,并将在未来版本中删除

您现在可以安全地忽略上述警告。

这是如何运作的?

该插件只是在解析的页面内容中查找 HTML 注释<!-- Actions Right -->,并在 之前插入“编辑链接”HTML <!-- Actions Right -->

这意味着如果 HTML 注释发生变化,这个插件就会崩溃,但我希望在发生这种情况时能够轻松修复它。

github

github 插件会在右上角添加一个 github 的图标,可以通过插件属性配置链接,点击后可以进入自定义的链接页面。

配置使用方法:

1
2
3
4
5
6
7
8
9
10
{
"plugins": \[
"github"
\],
"pluginsConfig": {
"github": {
"url": "https://github.com/jiangminggithub"
}
}
}

插件 Github 地址:https://github.com/GitbookIO/plugin-github

这个插件可以单击图片,以图片本身大小的方式弹窗显示图片和一些图片相关的 Alt 的信息。

配置使用方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"plugins": \[
"lightbox"
\],
"lightbox": {
"includeJQuery": false,
"sameUuid": true,
"options": {
"resizeDuration": 500,
"wrapAround": false
}
}
}

配置参数介绍:

  • includeJQuery: 如果你的项目中已经引入了 JQuery 可以在此设置是否包含插件本身的 JQuery。
  • sameUuid:在图片预览中添加上一个、下一个按钮来浏览本页面的图片配置。
  • options: 这个选项配置显示的动画时长,是否包裹等相关配置。

youtube

如何使用它?

将以下内容添加到您的book.json文件中,然后运行gitbook install

1
2
3
{
“插件” :\[ “ youtube ” \]
}

您现在可以使用此标签将 YouTube 视频添加到您的图书中:

看看这个视频:

1
2
3
{% youtube  %}
https://www.youtube.com/watch?v=hI6yCMjGoJs
{% endyoutube %}

该视频将被网站中的嵌入 iframe 以及电子书版本中的链接所取代。

gitbook-plugin-copyright 是基于Gitbook实现的版权保护插件,用于复制内容时追加版权信息以及文章末尾添加版权小尾巴.

🏠 主页

效果

copyright-use-preview.png

特色

  • 支持复制内容自动追加版本保护信息
  • 支持文章末尾自动生成版本保护尾巴
  • 支持自定义小尾巴版权保护图片
  • 支持 Gitbook 多语言环境

✨ 示例

不仅 gitbook-plugin-copyright 官方文档已整合 copyright 版权保护插件,此外还提供了示例项目,详情参考 example 目录.

1
2
3
4
5
6
7
8
9
10
11
12
{
"plugins": \["copyright"\],
"pluginsConfig": {
"copyright": {
"site": "https://snowdreams1006.github.io/gitbook-plugin-copyright",
"author": "雪之梦技术驿站",
"website": "雪之梦技术驿站",
"image": "https://snowdreams1006.github.io/snowdreams1006-wechat-open.png",
"copyProtect": false
}
}
}

🚀 用法

Step #1 - 更新 book.json 配置文件

  1. book.json 配置文件中,添加 copyrightplugins 列表.
  2. book.json 配置文件中,配置 pluginsConfig 对象.

单语言版简单示例 book.json

1
2
3
4
5
6
7
8
9
10
11
12
{
"plugins": \["copyright"\],
"pluginsConfig": {
"copyright": {
"site": "https://snowdreams1006.github.io/gitbook-plugin-copyright",
"author": "雪之梦技术驿站",
"website": "雪之梦技术驿站",
"image": "https://snowdreams1006.github.io/snowdreams1006-wechat-open.png",
"copyProtect": false
}
}
}

多语言版简单示例 book.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
"plugins": \["copyright"\],
"pluginsConfig": {
"copyright": {
"site": "https://snowdreams1006.github.io/gitbook-plugin-copyright",
"author": {
"en": "snowdreams1006",
"zh": "雪之梦技术驿站"
},
"website": {
"en": "snowdreams1006's Gitbook",
"zh": "雪之梦技术驿站"
},
"image": {
"en": "https://img.shields.io/badge/github-snowdreams1006-brightgreen.svg",
"zh": "https://snowdreams1006.github.io/snowdreams1006-wechat-open.png"
},
"copyProtect": false
}
}
}

其中,配置参数含义如下:

  • site : [必选]部署网站基本路径
  • author : [必选]作者信息
  • website : [必选]网站名称
  • image : [可选]版权保护图片
  • copyProtect : [可选]复制内容是否追加版权保护信息

Step #2 - 运行 gitbook 相关命令

  • 运行 gitbook install 命令安装到本地项目
1
gitbook install
  • 运行 gitbook build 命令构建本地项目或者 gitbook serve 启动本地服务.
1
gitbook build

或者

1
gitbook serve
  • 插件配置
1
2
3
4
5
6
7
"tbfed-pagefooter": {
"copyright":"&copy Taobao FED Team",
"modify\_label": "该文件修订时间:",
"modify\_format": "YYYY-MM-DD HH:mm:ss"
}

>>

copyright 和 modify_label 支持 html 代码

pageview-count

文档页面阅读数插件

Installation

In your book.json add the plugin:

1
2
3
4
5
{
"plugins": \[
"pageview-count"
\]
}

我的配置

插件安装命令

1
gitbook install ./

book.json文件如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
"title": "我的电脑",
"author": "zhl",
"description": "我的电脑安装软件工具合集",
"generator": "site",
"language": "zh-hans",
"links": {
"sidebar": {
"明": " http://www.xxx.com/"
}
},
"plugins": [
"accordion",
"hide-element",
"code",
"-sharing",
"sharing-plus",
"donate",
"anchor-navigation-ex",
"expandable-chapters",
"sidebar-style",
"splitter",
"emphasize",
"edit-link",
"github",
"lightbox",
"youtube",
"copyright",
"tbfed-pagefooter",
"pageview-count"
],
"pluginsConfig": {
"hide-element": {
"elements": [".gitbook-link"]
},
"sharing": {
"douban": false,
"facebook": false,
"google": true,
"pocket": false,
"qq": false,
"qzone": true,
"twitter": false,
"weibo": true,
"all": [
"douban", "facebook", "google", "instapaper", "linkedin","twitter", "weibo",
"messenger","qq", "qzone","viber","whatsapp"
]
},
"donate": {
"wechat": " https://gcore.jsdelivr.net/gh/xxx/PicGo/tubiao/weixin.jpg",
"alipay": " https://gcore.jsdelivr.net/gh/xxx/PicGo/tubiao/zhifubao.jpg",
"title": "鼓励一下",
"button": "赏",
"alipayText": "支付宝打赏",
"wechatText": "微信打赏"
},
"sidebar-style": {
"title": "我的电脑",
"author": "xxx作者"
},
"github": {
"url": " https://github.com/"
},
"edit-link": {
"base": " https://github.com/xxx/book/edit/html/",
"label": "编辑"
},
"lightbox": {
"includeJQuery": false,
"sameUuid": true,
"options": {
"resizeDuration": 200,
"wrapAround": true
}
},
"copyright": {
"site": " http://xx.xx.xxm",
"author": "xxx",
"website": "xx工作室",
"image": "",
"copyProtect": false
},
"tbfed-pagefooter": {
"copyright":"Copyright &copy namexxx 2022",
"modify_label": "该文件修订时间:",
"modify_format": "YYYY-MM-DD HH:mm:ss"
}
}
}