forked from ComputerScienceHouse/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewPost.sh
executable file
·48 lines (43 loc) · 1.18 KB
/
newPost.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
#!/bin/bash
read -p "Title: " title
read -p "Date [$(date +%Y-%m-%d)]: " date
read -p "Categories (space-separated): " categories
read -p "Description: " description
read -p "Post Image URL (full size): " img
read -p "Post Image URL (smaller): " img_sm
read -p "Author Name: " author_name
read -p "Author Image URL: " author_img
read -p "Author Bio: " author_bio
read -p "Author E-Mail: " author_email
read -p "Author GitHub URL: " author_github
read -p "Author LinkedIn URL: " author_linkedin
if [ -z "$date" ] # Default to current date
then
date=$(date +%Y-%m-%d)
fi
title_url=$(echo "$title" | tr " " "-" | tr '[:upper:]' '[:lower:]')
function add {
printf -- "$1\n" >> "_posts/$date-$title_url".md
}
# Append to file
add "---"
add "layout: post"
add "title: $title"
add "date: $date"
add "categories:"
for category in $categories
do
add " - $category"
done
add "description: $description"
add "image: $img"
add "image-sm: $img_sm"
add "author: $author_name"
add "author-image: $author_img"
add "author-bio: $author_bio"
add "author-email: $author_email"
add "author-social:"
add " github: $author_github"
add " linkedin: $author_linkedin"
add "---\n"
add "Post content goes here!"