File tree 2 files changed +49
-1
lines changed
2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,5 @@ This is a slow rebuild of neenjaw.com transitioned to jekyll (ruby-based)
7
7
## Todo
8
8
9
9
- style logo/header
10
- - post index
11
10
- post navigation
12
11
- colors
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ function main {
6
+ if [[ " ${# } " -eq 1 ]]; then
7
+ output_dir=" ./_posts"
8
+ title=" ${1} "
9
+ elif [[ " ${# } " -eq 2 && -d " ${1} " ]]; then
10
+ output_dir=$( realpath " ${1} " )
11
+ title=" ${2} "
12
+ else
13
+ die " USAGE: ./new_post.sh (<title>) | (<existing dir> <title>)"
14
+ fi
15
+
16
+ current_date=$( date +" %Y-%m-%d" )
17
+ current_time=$( date +" %H:%M:%S" )
18
+
19
+ new_post_content=(
20
+ " ---"
21
+ " layout: post"
22
+ " title: ${title} "
23
+ " date: ${current_date} ${current_time} -0600"
24
+ " categories: "
25
+ " ---"
26
+ )
27
+
28
+ printf ' %s\n' " ${new_post_content[@]} " > " ${output_dir} /${current_date} -${title} .markdown"
29
+ }
30
+
31
+ function installed {
32
+ cmd=$( command -v " ${1} " )
33
+
34
+ [[ -n " ${cmd} " ]] && [[ -f " ${cmd} " ]]
35
+ return ${?}
36
+ }
37
+
38
+ function die {
39
+ >&2 echo " Fatal: ${@ } "
40
+ exit 1
41
+ }
42
+
43
+ # Check for all required dependencies
44
+ deps=(realpath)
45
+ for dep in " ${deps[@]} " ; do
46
+ installed " ${dep} " || die " Missing '${dep} '"
47
+ done
48
+
49
+ main " $@ " ; exit
You can’t perform that action at this time.
0 commit comments