summaryrefslogtreecommitdiff
path: root/bin/make
blob: 3d9c6fd2de1de4886dee53a9600d41e63e4c7795 (plain)
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
#!/bin/sh -eu

. ./config

title() {
    [ -z "$1" ] && echo "$TITLE" && return
    echo "${1##*/} - $TITLE"
}

mkdir -p "$DIR_BUILD"

echo ">> Building content"

find "$DIR_CONTENT" -type f -name "*.$EXT_WRITINGS" | while read -r file; do
    base=${file#"$DIR_CONTENT"/}
    name=${base%."$EXT_WRITINGS"}

    outdir="$DIR_BUILD/$name"
    if [ "$name" = "index" ]; then
        output=$DIR_BUILD/index.html
        name=""
    else
        output="$outdir/index.html"
        mkdir -p "$outdir"
    fi

    case "$name" in
        *"${DIR_WRITINGS##*/}"*) name="$(sed -n '1s/^; //p' "$file")" ;;
    esac
    echo "  $output"
    markup < "$file" | makepage "$(title "$name")" > "$output"

done

echo ">> Generating writings indexes"

mkdir -p "$DIR_WRITINGS_DST"
echo "  $DIR_WRITINGS_DST/index.html"
makewritindex | makepage "$(title writings)" > "$DIR_WRITINGS_DST/index.html"

for c in $(categories "$DIR_WRITINGS"/*."$EXT_WRITINGS"); do
    mkdir -p "$DIR_WRITINGS_DST/$c"
    echo "  $DIR_WRITINGS_DST/$c/index.html"
    makewritindex "$c" | makepage "$(title "#$c")" > "$DIR_WRITINGS_DST/$c/index.html"
done

echo ">> Copying static content"
cp -rv "$DIR_STATIC"/* "$DIR_BUILD" | sed -E "s/.*-> '(.*)'/  \1/"