Skip to content

Instantly share code, notes, and snippets.

@TommyLau
Last active March 28, 2017 12:54
Show Gist options
  • Save TommyLau/cecf38fdd8fb7875d1c5 to your computer and use it in GitHub Desktop.
Save TommyLau/cecf38fdd8fb7875d1c5 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