-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjek.sh
More file actions
executable file
·68 lines (58 loc) · 1.39 KB
/
jek.sh
File metadata and controls
executable file
·68 lines (58 loc) · 1.39 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#
# Time-stamp: <Wednesday 2025-08-13 20:13:25 Jess Moore>
#
# Shorthand for building and serving jekyll site
#
# Usage: jek.sh [args...]
function usage() {
echo "Usage: jek.sh [-u] [arg]"
echo ""
echo "Description: Shorthand for building and serving jekyll site."
echo ""
echo "Arguments:"
echo " build: Build jekyll site"
echo " serve: Serve jekyll site locally."
echo ""
echo "Flags:"
echo " -u: Show unpublished pages. (Default: false)."
echo ""
exit 1 # Exit with a non-zero status to indicate an error
}
if [[ $# -eq 0 || $* == *"help"* || $* == *"-h"* ]]; then
usage
fi
JCMD="bundle exec jekyll"
# By default, show_unpub is false
show_unpub=false
# Parse arguments and flags
while getopts :hu opt; do
case $opt in
h) usage;;
u) show_unpub=true;;
\?) echo "Unknown option -$OPTARG"; exit 1;;
esac
done
# Shift positional parameters to remove processed options
shift $(( OPTIND - 1 ))
# Filename supplied
if [[ -n "$1" ]]; then
CMD="$1"
fi
case "${CMD}" in
'build')
echo "Building site...";;
'serve')
echo "Serving site locally...";;
*)
echo "Error ${CMD} is not in a supported jekyll command.";
usage;;
esac
if $show_unpub; then
echo "Including unpublished pages"
${JCMD} "${CMD}" "--unpublished"
else
echo "Published pages only"
${JCMD} "${CMD}"
fi
echo "Done."