-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·50 lines (39 loc) · 1.02 KB
/
build.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
#!/bin/bash
menuItems="About News Samples"
# inputfiles
mdFiles=`find . -name '*.md'`
# bulid all files
for mdFile in $mdFiles; do
dir=`dirname $mdFile`
base=`basename $mdFile .md`
html=$dir/$base.html
echo "" > $html
cat include/header0.inc >> $html
# add title
echo $base | sed "s/_/ /g" >> $html
cat include/header1.inc >> $html
echo "--------------------------------------------"
echo "mdFile $mdFile"
# build menu
for menuItem in $menuItems; do
isCurrentFile=`echo $menuItems | grep $base | wc -l`
echo -n '<li' >> $html
if [ -z $isCurrentFile ] ; then
echo -n '' >> $html
else
echo -n ' id="selected"' >> $html
fi
echo -n '><a href="' >> $html
echo -n $menuItem.html >> $html
echo -n '">' >> $html
echo -n $menuItem >> $html
echo -n '</a></li>' >> $html
done
cat include/header2.inc >> $html
# build header
pandoc $mdFile -o tmp.html
cat tmp.html >> $html
rm tmp.html
cat include/footer.inc >> $html
done
cp About.html index.html