forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preview-site.sh
executable file
·47 lines (38 loc) · 1019 Bytes
/
preview-site.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /bin/bash
if [[ "$1" == "--docker" ]]; then
docker run -ti --rm -p 4000:4000 -v $VTTOP:/vttop -w /vttop vitess/publish-site /vttop/preview-site.sh
exit $?
fi
set -e
PREVIEW_DIR=preview-vitess.io
rm -rf $PREVIEW_DIR
mkdir $PREVIEW_DIR
cp -rf vitess.io/* $PREVIEW_DIR
mkdir $PREVIEW_DIR/_includes/doc
mkdir -p $PREVIEW_DIR/_posts/doc
# create ref files for each doc
for d in doc/*.md
do
name=${d:4}
title=${name%%.*}
docpath="$PREVIEW_DIR/_posts/doc/2015-01-01-${name}"
touch $docpath
echo "---" >> $docpath
echo "layout: doc" >> $docpath
echo "title: \"$title\"" >> $docpath
echo "categories: doc" >> $docpath
echo "toc: true" >> $docpath
echo "---" >> $docpath
echo "{% include $d %}" >> $docpath
done
# preserve links between docs
for d in `ls doc/*.md` README.md index.md
do
python replace_doc_link.py doc $d > $PREVIEW_DIR/_includes/$d
done
# launch web site locally
cd $PREVIEW_DIR
bundle install
bundle exec jekyll serve --config _config_dev.yml
cd ..
rm -rf $PREVIEW_DIR