Skip to content

Instantly share code, notes, and snippets.

@100ideas
Forked from TommyLau/hexo_gitbook.sh
Created February 29, 2016 01:26
Show Gist options
  • Save 100ideas/d10eb730435be5b00e43 to your computer and use it in GitHub Desktop.
Save 100ideas/d10eb730435be5b00e43 to your computer and use it in GitHub Desktop.
Generate GitBook project for Hexo
#!/bin/sh
# Setup the directory name
DIRNAME=GitBook
# Remove the old GitBook directory
rm -fr $DIRNAME
mkdir $DIRNAME
# Generate the README.md
cat <<-EOF >$DIRNAME/README.md
# My Blog
This is auto generated file for editing blog with GitBook.
EOF
# Generate the SUMMARY.md
cat <<-EOF >$DIRNAME/SUMMARY.md
# Summary
* [Introduction](README.md)
EOF
for i in `ls -t source/_{drafts,posts}/*.md`; do
title=`cat $i | sed -n 's/title: \(.*\)/\1/p'`
echo "* [$title](../$i)" >> $DIRNAME/SUMMARY.md
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment