gitbook使用步骤

Step-1: 创建github仓库
Step-2: 克隆github仓库
git clone git@github.com:TOMGOU/algorithm-study.git
Step-3: 进入项目并初始化
// npm初始化
nmp init -y

// gitbook初始化
gitbook init
Step-4: 创建自动化发布shell脚本git.sh
cd _book
git init
git add .
git commit -m 'update'
git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages
cd ../

用户名:USERNAME = TOMGOU

仓库名:REPO = algorithm-study

Step-5: 修改package.json
"scripts": {
    "gh-pages": "./git.sh"
},
Step-6: 本地编辑
gitbook init (新增文件夹的时候,需要初始化)
gitbook serve
Step-7: github发布
npm run gh-pages
Step-8: gitbook plugin【添加文件:book.json,gitbook install】
{
  "title" : "数据结构与算法笔记",
  "author" : "tomgou",
  "description" : "数据结构与算法笔记",
  "language" : "zh-hans",
  "plugins": [
    "mathjax-pro",
    "github",
    "hide-element",
    "chapter-fold",
    "splitter",
    "-lunr", 
    "-search", 
    "search-pro",
    "copy-code-button",
    "back-to-top-button",
    "tbfed-pagefooter",
    "popup"
  ],
  "pluginsConfig": {
    "github": {
      "url": "https://tomgou.github.io/algorithm-study/"
    },
    "hide-element": {
      "elements": [".gitbook-link"]
    },
    "tbfed-pagefooter": {
      "copyright":"Copyright &copy tomgou 2022",
      "modify_label": "该文章修订时间:",
      "modify_format": "YYYY-MM-DD HH:mm:ss"
    }
  }
}

页面地址:https://tomgou.github.io/algorithm-study/

这样使用gitbook的好处

  • 不暴露源码(只要不push主分支)
  • 及时预览:gitbook serve
  • 及时发布:npm run gh-pages
Copyright © tomgou 2022 all right reserved,powered by Gitbook该文章修订时间: 2022-03-24 20:08:25

results matching ""

    No results matching ""