-
Notifications
You must be signed in to change notification settings - Fork 0
/
_new_post.sh
executable file
·49 lines (41 loc) · 1.09 KB
/
_new_post.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
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: provide a title argument"
exit -1
else
title="$@"
fi
slug=$(echo "$title" | tr "[:upper:]" "[:lower:]")
slug=$(echo "$slug" | sed "y/āáǎàēéěèīíǐìōóǒòūúǔùǖǘǚǜĀÁǍÀĒÉĚÈĪÍǏÌŌÓǑÒŪÚǓÙǕǗǙǛ/aaaaeeeeiiiioooouuuuüüüüAAAAEEEEIIIIOOOOUUUUÜÜÜÜ/")
slug=$(echo "$slug" | tr "[:punct:]" " ")
slug=$(echo "$slug" | tr _ " ")
slug=$(echo "$slug" | tr - " ")
slug=$(echo "$slug" | tr -s " ")
slug=$(echo "$slug" | tr "[:space:]" "-")
slug="${slug:0:${#slug}-1}"
y=$(date +"%Y")
m=$(date +"%m")
d=$(date +"%d")
post="./_drafts/$y-$m-$d-$slug.md"
body=""
read -d '' body <<EOF
---
layout: page
title: "$title"
description: "Description: $title"
image:
url: /img/blog/blog-placeholder.jpg
hide: false
tags:
- NetLicensing
author:
name: NetLicensing
url: https://labs64.com
sitemap:
images:
canonical:
---
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
EOF
echo "$body" > "$post"
echo Created new draft post: "$post"