-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsite
executable file
·60 lines (45 loc) · 1003 Bytes
/
site
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
#!/bin/bash
set -e # exit immediately on any error
action="$1"
shift
# make sure we are in the right dir if called from somewhere else
cd "$(dirname "$0")"
missing=""
abort() {
echo "$action: $*"
exit 1
}
case "$action" in
run)
bundle exec jekyll serve
;;
post)
# check for title parameters
if [ "$1" ]; then
title="$*"
else
abort "Missing title parameter"
fi
echo $title
title=$(echo $title | tr ' ' '-' | tr '[:upper:]' '[:lower:]')
echo $title
date=`date -u +"%Y-%m-%d"`
filename="_posts/${date}-$title.md"
echo $filename
user=`whoami`
author=`getent passwd $user | cut -d : -f 5`
cat > $filename <<EOT
---
title: Enter text here ...
date: $date
author: $author
layout: post
tags:
- ???
---
Enter text here in MarkDown format ...
EOT
$EDITOR $filename
echo "Run 'git add $filename' to save blog post"
;;
esac