88
99set -eu
1010
11- CMD=" JEKYLL_ENV=production bundle exec jekyll b"
12-
1311WORK_DIR=" $( dirname " $( dirname " $( realpath " $0 " ) " ) " ) "
1412
1513CONTAINER=" ${WORK_DIR} /.container"
1614
17- DEST=" ${WORK_DIR} /_site"
15+ dest=" ${WORK_DIR} /_site"
16+
17+ cmd=" JEKYLL_ENV=production bundle exec jekyll b"
1818
1919docker=false
2020
21+ config=" "
22+
2123_help () {
2224 echo " Usage:"
2325 echo
2426 echo " bash build.sh [options]"
2527 echo
2628 echo " Options:"
27- echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
28- echo " -h, --help Print the help information"
29- echo " -d, --destination <DIR> Destination directory (defaults to ./_site)"
30- echo " --docker Build site within docker"
29+ echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
30+ echo " -h, --help Print the help information"
31+ echo " -d, --destination <DIR> destination directory (defaults to ./_site)"
32+ echo " --docker Build site within docker"
33+ echo " --config <CONFIG_a[,CONFIG_b]> Specify config files"
3134}
3235
3336_install_tools () {
@@ -48,7 +51,7 @@ _init() {
4851 rm -rf " $CONTAINER "
4952 fi
5053
51- if [[ -d $DEST ]]; then
54+ if [[ -d $dest ]]; then
5255 bundle exec jekyll clean
5356 fi
5457
@@ -65,16 +68,21 @@ _build() {
6568 bash " _scripts/sh/create_pages.sh"
6669 bash " _scripts/sh/dump_lastmod.sh"
6770
68- CMD+=" -d $DEST "
69- echo " \$ $CMD "
70- eval " $CMD "
71- echo -e " \nBuild success, the site files have been placed in '${DEST} '."
71+ cmd+=" -d $dest "
72+
73+ if [[ -n $config ]]; then
74+ cmd+=" --config $config "
75+ fi
76+
77+ echo " \$ $cmd "
78+ eval " $cmd "
79+ echo -e " \nBuild success, the site files have been placed in '${dest} '."
7280
73- if [[ -d " ${DEST } /.git" ]]; then
74- if [[ -n $( git -C " $DEST " status -s) ]]; then
75- git -C " $DEST " add .
76- git -C " $DEST " commit -m " [Automation] Update site files." -q
77- echo -e " \nPlease push the changes of $DEST to remote master branch.\n"
81+ if [[ -d " ${dest } /.git" ]]; then
82+ if [[ -n $( git -C " $dest " status -s) ]]; then
83+ git -C " $dest " add .
84+ git -C " $dest " commit -m " [Automation] Update site files." -q
85+ echo -e " \nPlease push the changes of $dest to remote master branch.\n"
7886 fi
7987 fi
8088
@@ -97,20 +105,26 @@ main() {
97105 if [[ -z $_baseurl ]]; then
98106 _baseurl=' ""'
99107 fi
100- CMD +=" -b $_baseurl "
108+ cmd +=" -b $_baseurl "
101109 shift
102110 shift
103111 ;;
104112 -d | --destination)
105113 _check_unset " $2 "
106- DEST =" $( realpath " $2 " ) "
114+ dest =" $( realpath " $2 " ) "
107115 shift
108116 shift
109117 ;;
110118 --docker)
111119 docker=true
112120 shift
113121 ;;
122+ --config)
123+ _check_unset " $2 "
124+ config=" $( realpath " $2 " ) "
125+ shift
126+ shift
127+ ;;
114128 -h | --help)
115129 _help
116130 exit 0
0 commit comments