summaryrefslogtreecommitdiff
path: root/scripts/publish-raw
blob: cc9b02b1c70c55015f221f1e646b5c6102a00726 (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
#!/bin/sh

set -eu

content_dir=${1:-content}
public_dir=${2:-public}

[ -d "$content_dir" ] || exit 0
mkdir -p "$public_dir"

find "$content_dir" -type f -print | while IFS= read -r source
do
    relative=${source#"$content_dir"/}

    case "$relative" in
        updates/_index.md)
            # Updates is an aggregate index, not a published Markdown document.
            continue
            ;;
        journal/_index.md)
            target=$public_dir/journal/_index.md
            ;;
        journal/*/*/*/*)
            target=$public_dir/${relative#journal/}
            ;;
        journal/*)
            # The V1 model has no public year or month section documents.
            continue
            ;;
        *)
            target=$public_dir/$relative
            ;;
    esac

    mkdir -p "$(dirname "$target")"
    cp "$source" "$target"
done