-
Notifications
You must be signed in to change notification settings - Fork 0
/
createcategory
54 lines (41 loc) · 1.08 KB
/
createcategory
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
#!/bin/sh
# Using a 'cat' here document, create a file for jekyll
# website containing what's required for category pages.
# Pass in tag name(s)
# ./createcategory linux bsd
CMDLINEPARAM=1 # Takes at least one param.
CATEGORYDIR="pages/categories"
if [ $# -ge $CMDLINEPARAM ]
then
categories=$@
else
echo "Atleast ${CMDLINEPARAM} category name is required."
exit 1
fi
if [ -d "${CATEGORYDIR}" ]; then
echo "Creating category(s) for ${categories}"
for category in ${categories}; do
echo "Title for $category:"
read title
# Cannot indent here string.
cat <<EOF >"${CATEGORYDIR}/category_${category}.md"
---
title: "${title}"
categoryName: ${category}
search: exclude
permalink: category_${category}.html
sidebar: main_sidebar
hide_sidebar: true
folder: categories
---
{% include categorylogic.html %}
{% include links.html %}
EOF
echo " - ${category}" >> _data/categories.yml
done
else
echo "Directory ${CATEGORYDIR} doesn't exist or you are not in the top-level directory."
echo "Please run again from the root directory of your project."
exit 1
fi
exit