-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatepage
executable file
·64 lines (51 loc) · 1.27 KB
/
createpage
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
#!/bin/sh
# Using a 'cat' here document, create a file for jekyll
# website containing what's required for pages.
# You call the script without parameters
# ./createpage
DIR="pages/"
echo "Section? "
read section
# Convert to lowercase
section=$(echo $section | tr '[:upper:]' '[:lower:]')
DIR+=$section
echo "Name? "
read name
# Convert to lowercase
name=$(echo $name | tr '[:upper:]' '[:lower:]')
# Uppercase first letter
Section="$(tr '[:lower:]' '[:upper:]' <<< ${section:0:1})${section:1}"
Name="$(tr '[:lower:]' '[:upper:]' <<< ${name:0:1})${name:1}"
echo "Do you want a short section name? (y/n) "
read answer
case ${answer:0:1} in
y|Y )
echo "Short section name? "
read sec_short
# Convert to lowercase
sec_short=$(echo $sec_short | tr '[:upper:]' '[:lower:]')
;;
* )
sec_short=$section
;;
esac
if [ ! -d "${DIR}" ]; then
mkdir $DIR
fi
touch ${DIR}/${sec_short}_${name}.md
cat <<EOF >"${DIR}/${sec_short}_${name}.md"
---
title: ${Section} / ${Name}
tags: [${sec_short}, ${name}]
keywords: ${section}, ${name}
sidebar: wiki_sidebar
permalink: ${sec_short}_${name}.html
---
EOF
# Add tags
for tag in $sec_short $name; do
if ! egrep -q "^\s\s- $tag" _data/tags.yml; then
bash createtag $tag
fi
done
exit