blob: 8acdcdf3b4cacc5f8668cef73c14e6359c0b511e (
plain) (
blame)
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
|
#!/bin/bash
target () {
if [ "${1#*.}" = "md" ]; then
echo "output/$(echo "${1%.md}.html" | cut -sd / -f 2-)"
else
echo "output/$(echo "$1" | cut -sd / -f 2-)"
fi
}
handle () {
TARGET=$(target "$1")
mkdir -p $(dirname "$TARGET")
if [ "${1#*.}" = "md" ]; then
echo -e "\033[0;32m[COMPILE ]\033[0m $1 -> $TARGET"
pandoc "$1" \
-f markdown \
-t html5 \
--template templates/base.html \
-o "$TARGET" \
--metadata-file metadata/metadata.json
else
echo -e "\033[0;32m[COPY ]\033[0m $1 -> $TARGET"
cp "$1" "$TARGET"
fi
}
if [ -z "$1" ]; then
find content/ \
-type f \
| while read FILE
do
handle "$FILE"
done
elif [ "$1" = "md" ]; then
find content/ \
-type f \
-name "*.md" \
| while read FILE
do
handle "$FILE"
done
elif [ "$1" = "single" ]; then
if [ -z "$2" ]; then
echo -e "\033[0;31m[ERROR ]\033[0m \"single\" operation requires file argument"
else
handle "$2"
fi
elif [ "$1" = "delete" ]; then
if [ -z "$2" ]; then
echo -e "\033[0;31m[ERROR ]\033[0m \"delete\" operation requires file argument"
else
TARGET=$(target "$2")
echo -e "\033[0;32m[DELETE ]\033[0m $2 -> $TARGET"
rm -rf $TARGET
fi
else
echo -e "\033[0;31m[ERROR ]\033[0m Unknown operation: \"$1\""
fi
|