summaryrefslogtreecommitdiffstats
path: root/scripts/build_content.sh
blob: 992414de19f370b65240398bbd5fa185d002ff99 (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
#!/bin/bash

SITE_TITLE="Volpeon's Den"

target () {
    echo "dist/$(echo ${1%.md}.html | cut -sd / -f 2-)"
}

compile () {
  TARGET=$(target "$1")
  mkdir -p $(dirname "$TARGET")
  pandoc "$1" \
    -t html5 \
    --template templates/base.html \
    -o "$TARGET" \
    --metadata sitetitle="$SITE_TITLE"
}

if [ -z "$1" ]; then
    find content/ \
        -iname "*.md" \
        -type f \
        | while read FILE
            do
                compile "$FILE"
            done
else
    if [ "$2" = "delete" ]; then
        rm $(target $1)
    else
        compile "$1"
    fi
fi