-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathctl.sh
executable file
·68 lines (58 loc) · 2.08 KB
/
ctl.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# -e: exit on error
# -u: exit on unset variables
set -eu
NODE_VERSION=lts-bookworm
preview() {
docker run --rm -v $(pwd):/workspace -w /workspace -itp 8080:8080 node:$NODE_VERSION yarn quartz build --serve
}
# For full help options, you can run npx quartz sync --help.
#
# Most of these have sensible defaults but you can override them if you have a custom setup:
#
# -d or --directory: the content folder. This is normally just content
# -v or --verbose: print out extra logging information
# --commit or --no-commit: whether to make a git commit for your changes
# --push or --no-push: whether to push updates to your GitHub fork of Quartz
# --pull or --no-pull: whether to try and pull in any updates from your GitHub fork (i.e. from other devices) before pushing
sync() {
DRY=false python3 article-manager.py
quartz sync $@
}
node() {
docker run \
--rm \
-u 1000:1000 \
-v $(pwd):/home/node/quartz -v ~/.ssh:/home/node/.ssh \
-w /home/node/quartz \
node:$NODE_VERSION \
$@
}
init() {
node yarn install
}
quartz() {
node yarn quartz $@
}
show_menu() {
echo -e "\u001b[32;1m QUARTZ CTL MENU \u001b[0m"
echo -e " \u001b[37;1m\u001b[4m Options:\u001b[0m"
echo -e " \u001b[34;1m (0) perview | p => perview blog before publich \u001b[0m"
echo -e " \u001b[34;1m (1) sync => sync blog to remote repository, or update quartz \u001b[0m"
echo -e " \u001b[34;1m (2) sync --no-pull | sop => sync blog to remote repository but not update quartz \u001b[0m"
echo -e " \u001b[34;1m (3) quartz | q => run any quartz support sub commands \u001b[0m"
echo -e " \u001b[34;1m (4) dry => dry run to see what articles need update \u001b[0m"
echo -e " \u001b[34;1m (5) synatc | sa => sync articles from obsidian vault to this blog \u001b[0m"
}
main() {
case "$1" in
-m | --menu | m | menu | show_menu) show_menu ;;
p) preview;;
sop) sync --no-pull;;
dry) DRY=true python3 article-manager.py;;
synatc | sa) DRY=false python3 article-manager.py;;
*) "$@";;
esac
exit 0
}
main "$@"