#!/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/"