美文网首页
Gitbook——基础篇

Gitbook——基础篇

作者: Kiruru | 来源:发表于2019-03-19 12:46 被阅读0次

    基本操作

    参考链接

    安装

    • GitBook 命令行工具:npm install gitbook-cli -g
    • 查看版本:gitbook -V

    创建一本书

    • 初始化:gitbook init

    • 构建:gitbook build——在项目的目录下生成一个 _book 目录,里面的内容为静态站点的资源文件

    • 启动服务gitbook serve——运行一个 web 服务, 通过 http://localhost:4000/ 可以预览书籍

    • 生成电子书:

    # Generate a PDF file
    $ gitbook pdf ./ ./mybook.pdf
    
    # Generate an ePub file
    $ gitbook epub ./ ./mybook.epub
    
    # Generate a Mobi file
    $ gitbook mobi ./ ./mybook.mobi
    

    Gitbook配置和插件

    参考:【Gitbook】实用配置及插件介绍

    GitBook插件整理 - book.json配置

    其他 Q&A

    • How to remove “Published with Gitbook”

    • please create styles/website.css 文件链接

      .gitbook-link {
          display: none !important;
      }
      

      then, edit book.json文件链接

      {
          "styles": {
              "website": "styles/website.css"
          }
      }
      
    • gitbook build 生成的HTML无法跳转问题

    • 参考链接

    • 使用如下命令

      gitbook build --gitbook=2.6.7

      如果遇到:

      Error loading version latest: Error: Cannot find module 'internal/util/types'

      安装node管理 n

      • sudo npm install -g n

      降低版本,更新npm

      • sudo n 6

      安装npm

      • sudo npm install npm -g

      此时运行gitbook2.6.7的命令即可。

      • gitbook build --gitbook=2.6.7

      待转换完成后,将npm版本(例如11.11.1)切回来即可,以免影响其他模块

      • sudo n 11.11.1

    相关文章

      网友评论

          本文标题:Gitbook——基础篇

          本文链接:https://www.haomeiwen.com/subject/tgjgmqtx.html