天天看點

快速在 github 上部署 gitbook生成的靜态頁面

1. 建立 github 倉庫, clone 到本地目錄

git clone yourRepositoryUrl
           

2. 安裝 gitbook

百度搜尋如何安裝

3. 安裝 gitbook-summary

npm install -g gitbook-summary
           

4. 建立 push.sh

終端運作代碼

touch push.sh
chmod +x push.sh
           

代碼意思 : 建立了 push.sh , 然後改變權限, 使其可執行

5. 向 push.sh 寫入指令

echo 'make dictionary ...'
book sm -t 'leetcode 刷題筆記'

pwd=`pwd`
path=`basename $pwd`

echo 'gitbook build ...'
cd ../
gitbook build $path $path/docs

cd leetcode

echo 'git add all ...'
git add --all

res=`echo $?`
if [ "$res" != "0" ]
then 
    exit 1
    echo '---->> error : git add failed'
fi

echo 'git commit ...'
'git commit -a -m "add md file"

res=`echo $?`
if [ "$res" != "0" ]
then
    exit 1
    echo '---->> error : git commit failed'

fi

echo 'git push ...'
git push

res=`echo $?`
if [ "$res" != "0" ]
then
    exit 1
     echo '---->> error : git push failed'

fi

           

6. 運作 push.sh

./push.sh
           

7. 在 github 倉庫設定頁面打開 pages

上面的連結就是頁面位址

快速在 github 上部署 gitbook生成的靜态頁面