2.4.1. 配置

所有的配置都以 JSON 格式存储在名为 book.json 的文件中。

你可以粘贴你的 book.json 去 jsonlint.com 验证 JSON 语法。

该配置与 SUMMARY.md 同级:

.
├── book.json
├── README.md
└── SUMMARY.md

2.4.1.1. 示例

{
    "title": "GitBook 使用教程",
    "description": "记录 GitBook 的配置和一些插件的使用",
    "author": "xxxx",
    "output.name": "site",
    "language": "zh-hans",
    "gitbook": "3.2.2",
    "root": ".",
    "structure": {
        "readme": "introduction.md"
    },
    "links": {
        "sidebar": {
            "Home": "http://www.xxxx.com"
        }
    },
    "plugins": [
        "-lunr",
        "-search",
        "-highlight",
        "-livereload",
        "search-plus@^0.0.11",
        "simple-page-toc@^0.1.1",
        "github@^2.0.0",
        "[email protected]",
        "edit-link@^2.0.2",
        "disqus@^0.1.0",
        "prism@^2.1.0",
        "prism-themes@^0.0.2",
        "advanced-emoji@^0.2.1",
        "anchors@^0.7.1",
        "include-codeblock@^3.0.2",
        "ace@^0.3.2",
        "emphasize@^1.1.0",
        "katex@^1.1.3",
        "splitter@^0.0.8",
        "tbfed-pagefooter@^0.0.1",
        "expandable-chapters-small@^0.1.7",
        "sectionx@^3.1.0",
        "donate@^1.0.2",
        "local-video@^1.0.1",
        "sitemap-general@^0.1.1",
        "[email protected]",
        "favicon@^0.0.2",
        "todo@^0.1.3",
        "3-ba@^0.9.0"
    ],
    "pluginsConfig": {
        "theme-default": {
            "showLevel": true
        },
        "disqus": {
            "shortName": "gitbookuse"
        },
        "prism": {
            "css": [
                "prism-themes/themes/prism-base16-ateliersulphurpool.light.css"
            ]
        },
        "github": {
            "url": "https://xxxxxx"
        },
        "github-buttons": {
            "repo": "xxxxx/gitbook-use",
            "types": [
                "star"
            ],
            "size": "small"
        },
        "include-codeblock": {
            "template": "ace",
            "unindent": true,
            "edit": true
        },
        "sharing": {
            "weibo": true,
            "facebook": true,
            "twitter": true,
            "google": false,
            "instapaper": false,
            "vk": false,
            "all": [
                "facebook",
                "google",
                "twitter",
                "weibo",
                "instapaper"
            ]
        },
        "tbfed-pagefooter": {
            "copyright": "Copyright © xxxx.com 2017",
            "modify_label": "该文件修订时间:",
            "modify_format": "YYYY-MM-DD HH:mm:ss"
        },
        "3-ba": {
            "token": "fxxxxxxxx"
        },
        "donate": {
            "wechat": "https://xxxxx/weixin.png",
            "alipay": "https://xxxxx/alipay.png",
            "title": "",
            "button": "赏",
            "alipayText": "支付宝打赏",
            "wechatText": "微信打赏"
        },
        "simple-page-toc": {
            "maxDepth": 3,
            "skipFirstH1": true
        },
        "edit-link": {
            "base": "https://xxxxxx",
            "label": "Edit This Page"
        },
        "sitemap-general": {
            "prefix": "http://xxxxx.com"
        },
        "anchor-navigation-ex": {
            "isRewritePageTitle": false,
            "tocLevel1Icon": "fa fa-hand-o-right",
            "tocLevel2Icon": "fa fa-hand-o-right",
            "tocLevel3Icon": "fa fa-hand-o-right"
        },
        "sectionx": {
            "tag": "b"
        },
        "favicon": {
            "shortcut": "favicon.ico",
            "bookmark": "favicon.ico"
        }
    }
}

2.4.1.2. title

设置书本的标题

{"title" : "Gitbook Use"}

2.4.1.3. author

作者的相关信息

{"author" : "heyhey"}

2.4.1.4. description

本书的简单描述,默认是从 README(第一段)中提取的。在 gitbook.com 中,这个值是根据平台输入的描述定义的。

{"description" : "记录Gitbook的配置和一些插件的使用"}

2.4.1.5. isbn

这个选项定义了你书本的ISBN。

{ "isbn": "9xx-3-xx6-1xx41x-0" }

2.4.1.6. theme-default

为目录添加序号

"theme-default": {
            "showLevel": true
        }

2.4.1.7. language

Gitbook 使用的语言, 可选的语言如下:

en, ar, bn, cs, de, en, es, fa, fi, fr, he, it, ja, ko, no, pl, pt, ro, ru, sv, uk, vi, zh-hans, zh-tw

配置使用简体中文

{"language" : "zh-hans"}

2.4.1.8. gitbook

指定使用的gitbook版本

{"gitbook" : "3.2.2"}

2.4.1.9. root

指定存放 GitBook 文件(除了 book.json)的根目录

{"root": "."}

在左侧导航栏(Home)添加链接信息

"links" : {
    "sidebar" : {
        "Home" : "https://www.gitbook.com"
    }
}

2.4.1.11. direction

{ "direction": "rtl" }

这个选项是用来重新设置语言的文字方向的。建议将 language 字段设置为带有正确的文字方向的语言

2.4.1.12. styles

自定义页面样式, 默认情况下各 generator 对应的 css 文件

{
    "styles": {
        "website": "styles/website.css",
        "ebook":   "styles/ebook.css",
        "pdf":     "styles/pdf.css",
        "mobi":    "styles/mobi.css",
        "equb":    "styles/epub.css"
    }
}

例如使<h1> <h2>标签有下边框, 可以在 website.css 中设置

h1 , h2{
    border-bottom: 1px solid #EFEAEA;
}

2.4.1.13. plugins

配置使用的插件

{ "plugins": ["mathjax"] }

书本使用的插件列表被定义在 book.json 的配置中。

添加新插件之后需要运行 gitbook install 来安装新的插件

2.4.1.14. pluginsConfig

配置插件的属性

{
    "plugins": ["myplugin"],
    "pluginsConfig": {
        "myPlugin": {
            "message": "Hello World"
        }
    }
}

2.4.1.15. structure

指定 Readme、Summary、Glossary 和 Languages 对应的文件名,下面是这几个文件对应变量以及默认值:

变量 含义和默认值
structure.readme Readme file name (defaults to README.md)
structure.summary Summary file name (defaults to SUMMARY.md)
structure.glossary Glossary file name (defaults to GLOSSARY.md)
structure.languages Languages file name (defaults to LANGS.md)

例如你想要使用 INTRO.md 代替 README.md :

{
    "structure": {
        "readme": "INTRO.md"
    }
}
Copyright © augustdoit 2020 all right reserved,powered by Gitbook该文件修订时间: 2020-10-12 14:43:08

results matching ""

    No results matching ""