-
Notifications
You must be signed in to change notification settings - Fork 18
/
generate-markdown.sh
executable file
·44 lines (31 loc) · 1.11 KB
/
generate-markdown.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
#!/bin/bash
cd "$( dirname "${BASH_SOURCE[0]}")"
mkdir content
rm -r content/*.md
cp markdown/about.md content/about.md
rank=0
while IFS='' read -r line || [[ -n "$line" ]]; do
# get the table columns
entryname=`echo "$line" | cut -d$',' -f1`
parent=`echo "$line" | cut -d$',' -f2`
repourl=`echo "$line" | cut -d$',' -f3`
readmeurl=`echo "$line" | cut -d$',' -f4`
includetext=""
permalink=`echo "$entryname" | sed "s/ /_/g"`
# generating the header of each page
if [ -n "$repourl" ]
then
includetext=`echo '**[Edit this page with Git]('$repourl')**'`
fi
# generate jekyll header
if [ -z "$parent" ]
then
echo -e "---\nlayout: readme\ntitle: \"$entryname\"\npermalink: \"$permalink\"\nrank: $rank\n---\n" > "content/$entryname.md"
else
echo -e "---\nlayout: subpage\ntitle: \"$entryname\"\npermalink: \"$permalink\"\nparent: \"$parent\"\nrank: $rank\n---\n" > "content/$entryname.md"
fi
# filling with header and page content
echo -e "$includetext\n" >> "content/$entryname.md"
curl -s "$readmeurl" >> "content/$entryname.md"
((rank+=1))
done < <(tail -n+2 readme-list.csv)