8
8
9
9
set -eu
10
10
11
- CMD=" JEKYLL_ENV=production bundle exec jekyll b"
12
-
13
11
WORK_DIR=" $( dirname " $( dirname " $( realpath " $0 " ) " ) " ) "
14
12
15
13
CONTAINER=" ${WORK_DIR} /.container"
16
14
17
- DEST=" ${WORK_DIR} /_site"
15
+ dest=" ${WORK_DIR} /_site"
16
+
17
+ cmd=" JEKYLL_ENV=production bundle exec jekyll b"
18
18
19
19
docker=false
20
20
21
+ config=" "
22
+
21
23
_help () {
22
24
echo " Usage:"
23
25
echo
24
26
echo " bash build.sh [options]"
25
27
echo
26
28
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"
31
34
}
32
35
33
36
_install_tools () {
@@ -48,7 +51,7 @@ _init() {
48
51
rm -rf " $CONTAINER "
49
52
fi
50
53
51
- if [[ -d $DEST ]]; then
54
+ if [[ -d $dest ]]; then
52
55
bundle exec jekyll clean
53
56
fi
54
57
@@ -65,16 +68,21 @@ _build() {
65
68
bash " _scripts/sh/create_pages.sh"
66
69
bash " _scripts/sh/dump_lastmod.sh"
67
70
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} '."
72
80
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"
78
86
fi
79
87
fi
80
88
@@ -97,20 +105,26 @@ main() {
97
105
if [[ -z $_baseurl ]]; then
98
106
_baseurl=' ""'
99
107
fi
100
- CMD +=" -b $_baseurl "
108
+ cmd +=" -b $_baseurl "
101
109
shift
102
110
shift
103
111
;;
104
112
-d | --destination)
105
113
_check_unset " $2 "
106
- DEST =" $( realpath " $2 " ) "
114
+ dest =" $( realpath " $2 " ) "
107
115
shift
108
116
shift
109
117
;;
110
118
--docker)
111
119
docker=true
112
120
shift
113
121
;;
122
+ --config)
123
+ _check_unset " $2 "
124
+ config=" $( realpath " $2 " ) "
125
+ shift
126
+ shift
127
+ ;;
114
128
-h | --help)
115
129
_help
116
130
exit 0
0 commit comments