File tree 2 files changed +60
-0
lines changed
2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -eu -o pipefail
3
+
4
+ POST_DATE=$( date +" %Y-%m-%d" )
5
+ POST_YEAR=$( date +" %Y" )
6
+ POST_MONTH=$( date +" %m" )
7
+ POST_DAY=$( date +" %d" )
8
+ POST_TITLE=$1
9
+
10
+ function slug_from_title_and_date {
11
+ echo " $POST_DAY -$1 " | tr ' [:upper:]' ' [:lower:]' | tr -s ' ' ' -' | tr -s ' [:punct:]' ' -'
12
+ }
13
+
14
+ function make_folder_path {
15
+ local slug=" $1 "
16
+ echo " content/$POST_YEAR /$POST_MONTH /$slug "
17
+ }
18
+
19
+ function file_path {
20
+ local slug=" $1 "
21
+ local folder_path=" $2 "
22
+ echo " $folder_path /${slug} .md"
23
+ }
24
+
25
+ function create_post {
26
+ local file_path=" $1 "
27
+ echo " Creating post at $file_path "
28
+ touch " $file_path "
29
+ echo " ---" >> " $file_path "
30
+ echo " title: $POST_TITLE " >> " $file_path "
31
+ echo " date: $POST_DATE " >> " $file_path "
32
+ echo " draft: true" >> " $file_path "
33
+ echo " ---" >> " $file_path "
34
+ }
35
+
36
+ function main {
37
+ local slug=" $( slug_from_title_and_date " $POST_TITLE " ) "
38
+ local folder_path=" $( make_folder_path " $slug " ) "
39
+ local file_path=" $( file_path " $slug " " $folder_path " ) "
40
+ mkdir -p " $folder_path "
41
+ create_post " $file_path "
42
+ }
43
+
44
+ main
45
+
46
+
Original file line number Diff line number Diff line change 1
1
services :
2
+ dist :
3
+ image : node:18-bullseye
4
+ command : ["npm", "run", "dist"]
5
+ volumes :
6
+ - .:/src
7
+ working_dir : /src
8
+
9
+ dist_clean :
10
+ volumes :
11
+ - .:/src
12
+ working_dir : /src
13
+ image : node:18-bullseye
14
+ command : ["rm", "-rf", "dist"]
15
+
2
16
web :
3
17
build : _drafts/staging
4
18
ports :
You can’t perform that action at this time.
0 commit comments