-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathaddsite.sh
executable file
·77 lines (57 loc) · 1.23 KB
/
addsite.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
function heading {
echo $(tput bold)$(tput setaf 1)$@ $(tput sgr 0)
}
function bold {
echo $(tput bold)$(tput setaf 4)$@ $(tput sgr 0)
}
function slugify {
echo "$1" | iconv -t ascii//TRANSLIT | sed -E s/[^a-zA-Z0-9]+/-/g | sed -E s/^-+\|-+$//g | tr A-Z a-z
}
# -------------------------------
echo
heading "Creating a new site."
echo
bold "What is the title?"
read title
echo
bold "What is the first author name?"
read author
echo
bold "What is the URL?"
read url
echo
bold "What is the type? Current types: personal, blog, company, project, or docs"
read type
echo
bold "What is the open source repo URL, if there is one?"
read repo
echo
bold "Was this site created using the Jigsaw generators? (Y/N)"
read generators
generators=${generators::1}
if [ $generators == "Y" ] || [ $generators == "y" ] ; then
usedGenerator=true
else
usedGenerator=false
fi
slug=`slugify "$title"`
# -------------------------------
buildpath="$PWD/source/_sites/$slug.md"
echo
bold "Creating a file at:"
echo $buildpath
touch $buildpath
date=`date +%Y-%m-%d`
cat <<EOT >> $buildpath
---
title: "$title"
authors: [$author]
url: $url
added: $date
types: [$type]
repo: $repo
usedGenerator: $usedGenerator
---
EOT
vim $buildpath