게을러지지마 / gitbook 만들기

GitBook Tutorial

book : aws algorithm

GitBook 생성방법

요구사항

gitbook-cli 설치

$ npm install gitbook-cli -g 

gitbook init

# 해당 디렉토리에서
$ gitbook init

local server start

$ gitbook serve

# ...
# Starting server ...
# Serving book on http://localhost:4000

branch는 gh-pages로 변경

$ git checkout -b gh-pages

# push도 gh-pages로 한다.

목차 생성 파일

Summary

SUMMARY.md 예시

* [Introduction](README.md)  
  
* [Part I](part1/README.md)  
	* [Writing is nice](part1/writing.md)  
	* [GitBook is nice](part1/gitbook.md)  
* [Part II](part2/README.md)  
	* [We love feedback](part2/feedback_please.md)  
	* [Better tools for authors](part2/better_tools.md)  

Gitbook 디렉터리 구조

├── book.json            # 기본 GitBook구성 데이터(선택)  
├── README.md            # 책 소개(필수)  
├── SUMMARY.md           # 목차 참조(선택)  
├── GLOSSARY.md          # 용어 정리(선택 : 직접파일 성생필요)   
├── part-1/  
|   ├── README.md  
|   └── something.md  
└── part-2/  
    ├── README.md  
    └── something.md  

# book.json에서는 플러그인을 세팅 할 수 있다.

배포

  1. repository를 생성
  2. gh-pages 브랜치를 생성
  3. _books/ 디렉터리를 반영하면 t-g-kim.github.io/repo-name 으로 gitbook이 반영
# ../book-algorithm/ 에서 파일생성 및 gitbook serve 했다고 가정   
$ cp -R ../{book_name}/_book/* . #*  
$ git clean -fx node_modules  
$ git clean -fx _book  

배포 요약

git add .
git commit -m"message"
git push origin gh-pages

배포과정 shell

#!/bin/bash

# console message
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"

cp -R ../boo.algorithm/_book/* .

git clean -fx node_modules

git clean -fx _book

git add .
# Commit changes.
msg="rebuilding site `date`"
if [ $# -eq 1 ]
  then msg="$1"
fi
git commit -m "$msg"

# Push source and build repos.
git push origin gh-pages