最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【整理】Gitbook中的book.json参数配置

gitbook crifan 7412浏览 0评论

折腾:

【已解决】Gitbook中添加章节的编号

期间,需要先去给Gitbook创建合适的book.json,加上必要的基本的配置。

然后再去添加其他配置参数。

关于book.json的配置,可以参考别人的:

bookjson · GitBook 使用教程

同时再去找找官网的介绍

gitbook book.json

Configuration · GitBook Toolchain Documentation

Configuration · GitBook Toolchain Documentation

Configuration | GitBook.com Documentation

book.json | GitBook 简明教程

再去看看自己当前的gitbook的版本号:

➜  htttp_summary git:(master) gitbook –version

CLI version: 2.3.2

GitBook version: 3.2.3

关于语言language,参考:

List of ISO 639-1 codes – Wikipedia

应该是zh表示中文

然后去创建一个基本的book.json:

{

  “title”: “HTTP知识总结”,

  “description”: “总结HTTP方面的技术供参考和学习”,

  “author”: “Crifan Li <[email protected]>”,

  “language”: “zh”,

  “gitbook”: “3.2.3”,

  “root”: “.”,

  “links”: {

    “sidebar”: {

      “主页”: “https://www.crifan.com”;

    }

  },

  “plugins”: [

    “-search”

  ]

}

效果是:

去掉了search

添加了主页

zh的language,使得github的文字变成繁体了。

所以参考:

https://gitbook.zhangjikai.com/bookjson.html

去改为:

“language”: “zh-hans”,

结果就变成简体中文了:

【总结】

参考官网和其他资料,目前添加了book.json:

{

  “title”: “HTTP知识总结”,

  “description”: “总结HTTP方面的技术供参考和学习”,

  “author”: “Crifan Li <[email protected]>”,

  “language”: “zh-hans”,

  “gitbook”: “3.2.3”,

  “root”: “.”,

  “links”: {

    “sidebar”: {

      “主页”: “https://www.crifan.com”;,

      “Github源码”: “https://github.com/crifan/http_summary”;

    }

  },

  “plugins”: [

    “-search”

  ]

}

然后去:

gitbook serve

后的本地效果是:

注:

后续供参考的book.json中的配置有:

bookjson · GitBook 使用教程

book.json | GitBook 简明教程

bookjson | gitbook-use(用户手册)

官网的:

Configuration | GitBook.com Documentation

Configuration · GitBook Toolchain Documentation

【后记】

后来折腾后,一个比较完整的book.json的内容为:

<code>{
  "title": "HTTP知识总结",
  "description": "总结HTTP方面的技术供参考和学习",
  "author": "Crifan Li &lt;[email protected]&gt;",
  "language": "zh-hans",
  "gitbook": "3.2.3",
  "root": "./src",
  "links": {
    "sidebar": {
      "主页": "https://www.crifan.com"
    }
  },
  "plugins": [
    "theme-comscore",
    "-lunr",
    "-search",
    "search-plus",
    "disqus",
    "-highlight",
    "prism",
    "prism-themes",
    "github-buttons",
    "splitter",
    "-sharing",
    "sharing-plus",
    "tbfed-pagefooter",
    "expandable-chapters-small",
    "ga",
    "donate",
    "sitemap-general",
    "copy-code-button",
    "alerts",
    "toolbar-button"
  ],
  "pluginsConfig": {
    "theme-default": {
        "showLevel": true
    },
    "disqus": {
      "shortName": "crifan"
    },
    "prism": {
      "css": [
        "prism-themes/themes/prism-atom-dark.css"
      ]
    },
    "github-buttons": {
      "buttons": [
        {
          "user": "crifan",
          "repo": "http_summary",
          "type": "star",
          "count": true,
          "size": "small"
        }, {
          "user": "crifan",
          "type": "follow",
          "width": "120",
          "count": false,
          "size": "small"
        }
      ]
    },
    "sharing": {
      "douban": false,
      "facebook": true,
      "google": false,
      "hatenaBookmark": false,
      "instapaper": false,
      "line": false,
      "linkedin": false,
      "messenger": false,
      "pocket": false,
      "qq": true,
      "qzone": false,
      "stumbleupon": false,
      "twitter": true,
      "viber": false,
      "vk": false,
      "weibo": true,
      "whatsapp": false,
      "all": [
        "douban",
        "facebook",
        "google",
        "instapaper",
        "line",
        "linkedin",
        "messenger",
        "pocket",
        "qq",
        "qzone",
        "stumbleupon",
        "twitter",
        "viber",
        "vk",
        "weibo",
        "whatsapp"
      ]
    },
    "tbfed-pagefooter": {
      "copyright": "crifan.com,使用&lt;a href='https://creativecommons.org/licenses/by-sa/4.0/deed.zh'&gt;知识署名-相同方式共享4.0协议&lt;/a&gt;发布",
      "modify_label": "该文件修订时间:",
      "modify_format": "YYYY-MM-DD HH:mm:ss"
    },
    "ga": {
      "token": "UA-28297199-1"
    },
    "donate": {
      "wechat": "https://www.crifan.com/files/res/crifan_com/crifan_wechat_pay.jpg",
      "alipay": "https://www.crifan.com/files/res/crifan_com/crifan_alipay_pay.jpg",
      "title": "",
      "button": "打赏",
      "alipayText": "支付宝打赏给Crifan",
      "wechatText": "微信打赏给Crifan"
    },
    "sitemap-general": {
      "prefix": "https://book.crifan.com/gitbook/http_summary/website/"
    },
    "toolbar-button": {
      "icon": "fa-file-pdf-o",
      "label": "下载PDF",
      "url": "http://book.crifan.com/books/http_summary/pdf/http_summary.pdf"
    }
  }
}
</code>

更新更完整的代码可参考:

https://github.com/crifan/http_summary/blob/master/book.json

转载请注明:在路上 » 【整理】Gitbook中的book.json参数配置

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.167 seconds, using 22.21MB memory