wiki/build.sh

31 lines
858 B
Bash
Raw Normal View History

2021-03-21 11:40:01 +00:00
#!/bin/bash
shopt -s globstar
# Preprocess include-after.html
tmpfile=$(mktemp "/tmp/$USER.XXXXXXXXXX")
trap "rm \"$tmpfile\"" EXIT
sed "s/{{ now }}/$(date --iso-8601=seconds)/g;s/{{ generator }}/$(pandoc --version | head -n1)/g" include-after.html > "$tmpfile"
for file in content/**/*.md; do
output="${file/#content/html}"
output="${output/%.md/.html}"
mkdir -p "$(dirname "$output")"
echo "Building $file to $output"
pandoc \
--read markdown \
--write html \
--standalone \
--include-in-header include-header.html \
--include-before-body include-before.html \
--include-after-body "$tmpfile" \
--css $(echo "$(dirname $(dirname "$file"))/theme.css" | sed 's|^\./||;s|[^/]*/|../|g') \
-o "$output" \
"$file"
done
for src in assets/*; do
dest="${src/#assets/html}"
echo "Symlinking $src to $dest"
ln -fTs "../$src" "$dest"
done