blog/build.sh

51 lines
915 B
Bash
Executable File

#!/bin/bash
### Configuration variables ###
BLOG_TITLE_PREFIX="ziman's blog"
### Rendering commands ###
render() {
pandoc \
-s -T "$BLOG_TITLE_PREFIX" \
--base-header-level=2 \
-f rst -t html5 \
-H wrappers/art_header.html \
-B wrappers/art_before_body.html \
"$@"
}
render_article() {
render -A wrappers/art_after_body.html "$@"
}
render_index() {
render -A wrappers/index_after_body.html "$@"
}
### Main program ###
index="out/index"
echo "$BLOG_TITLE_PREFIX" > $index.rst
echo "==================" >> $index.rst
echo "" >> $index.rst
for root in $(cd articles; ls -1 | cut -d. -f1 | tac); do
rst="articles/${root}.rst"
html="out/${root}.html"
title=$(head -n1 "$rst")
date="$(echo "$root" | cut -d- -f1-3)"
echo "$date - $title"
render_article "$rst" -o "$html"
echo "- $date -- \`$title <${root}.html>\`_" >> $index.rst
done
render_index "$index.rst" -o "$index.html"