Skip to content

Commit 73aca1e

Browse files
committed
support output dir
1 parent 93f251b commit 73aca1e

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

scripts/build.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22

33
function parse_args() {
44
locale="en" # Default locale
5+
out_dir="" # Default empty, meaning no custom output directory
56

67
while [[ "$#" -gt 0 ]]; do
78
case "$1" in
89
-l|--locale)
910
locale="$2"
1011
shift 2
1112
;;
13+
--out-dir)
14+
out_dir="$2"
15+
shift 2
16+
;;
1217
-h|--help)
13-
echo "Usage: $0 [-l locale]"
18+
echo "Usage: $0 [-l locale] [--out-dir path]"
1419
echo ""
1520
echo "Options:"
1621
echo " -l, --locale Locale to build docs for (default: en)."
22+
echo " --out-dir Specify output directory for the build."
1723
echo " -h, --help Display this help message."
1824
exit 0
1925
;;
@@ -29,11 +35,26 @@ main() {
2935
parse_args "$@"
3036

3137
echo "Building Docusaurus with locale: en (currently required)"
32-
GENERATE_SOURCEMAP=false docusaurus build --locale en
38+
build_command="GENERATE_SOURCEMAP=false docusaurus build --locale en"
39+
40+
# Append output directory if provided
41+
if [[ -n "$out_dir" ]]; then
42+
build_command+=" --out-dir $out_dir/en"
43+
fi
44+
45+
# Execute the build command for English
46+
eval "$build_command"
3347

3448
if [[ "$locale" != "en" ]]; then
3549
echo "Building Docusaurus with additional locale: $locale"
36-
GENERATE_SOURCEMAP=false docusaurus build --locale "$locale"
50+
build_command="GENERATE_SOURCEMAP=false docusaurus build --locale $locale"
51+
52+
if [[ -n "$out_dir" ]]; then
53+
build_command+=" --out-dir $out_dir/$locale"
54+
fi
55+
56+
# Execute the build command for the additional locale
57+
eval "$build_command"
3758
fi
3859
}
3960

0 commit comments

Comments
 (0)