1function pandoc_cmd() {
2 pandoc --standalone --template template.html - "$@"
3}
4
5function gen() {
6 echo "---"
7 echo "title: List of things"
8 echo "---"
9
10 echo "# Index of articles"
11
12 find output -name '*.html' -printf '%P\n' | grep -v 'index.html' | while read f; do
13 title="$(grep '<title>' "output/$f" | perl -p -e "s#.*<title>(.*)</title>#\1#")"
14 last="$(grep -oE 'Last modified: [0-9\-]+' "output/$f")"
15 echo "* [$title]($f) ($last)"
16 done | sort -t'(' -k 3
17}
18
19gen | pandoc_cmd --metadata footer="Generated at: $(date +%Y-%m-%d)" -o "$1"