-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblog
More file actions
executable file
·61 lines (47 loc) · 1000 Bytes
/
blog
File metadata and controls
executable file
·61 lines (47 loc) · 1000 Bytes
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
#!/usr/bin/env bash
set -Eeo pipefail
CONTENT_DIR=content/blog
function check_hugo {
if ! command -v hugo >/dev/null; then
echo "Hugo not found, exiting..."
exit 1
fi
}
function check_git {
if ! command -v git >/dev/null; then
echo "Git not found, exiting..."
exit 1
fi
}
function server {
check_hugo
echo "Starting Hugo server..."
hugo server --buildDrafts $@
}
function draft {
check_hugo
echo "Creating new draft $@"
hugo new --kind blog ${CONTENT_DIR}/$@
}
function undraft {
check_hugo
local new_filename=${CONTENT_DIR}/$(date +"%F")-$@
echo "Undrafting ${CONTENT_DIR}/$@..."
mv ${CONTENT_DIR}/$@ $new_filename
sed -i '' "/draft: true/d" $new_filename
echo "Undraft complete..."
}
case "$1" in
server)
server $2
;;
draft)
draft $2
;;
undraft)
undraft $2
;;
*)
echo $"Usage: $0 {server|draft <draft-name>.md|undraft <draft-name>.md}"
exit 1
esac