···7788[this](https://github.com/chfour/nixos/blob/main/machines/fovps/services/caddy/default.nix)
99is the other part of the code that makes this run and it is Cursed because of caching
1010+1111+run the following to serve everything locally:
1212+`nix run nixpkgs#caddy -- file-server -l 0.0.0.0:8000 -a -r "$(nix build .#website.out --no-link --print-out-paths)/var/www"`
+28
buildblog.sh
···11+#!/usr/bin/env sh
22+33+template_start='<!--BEGIN TEMPLATE-->'
44+template_end='<!--END TEMPLATE-->'
55+66+[ -n "$1" ] && cd "$1"
77+88+sed "/${template_start}/q" ./index_template.html > ./index.html
99+1010+# this... thing turns the template in the html into a json string with jq string interpolation, to be passed back into jq
1111+# thankfully this only has to be done once. cursedd
1212+template="$(sed "/\s*${template_start}/,/\s*${template_end}/!d;//d" ./index_template.html | \
1313+ jq -Rs '"\"" + (gsub("(?<s>^|}})(?<p>.+?)(?<e>{{|$)"; "\(.s + (.p|@json|trimstr("\"")) + .e)"; "m") | rtrim | gsub("{{(?<p>.+?)}}"; "\\(\(.p))"; "m")) + "\""' -r)"
1414+1515+find . -name content.djot -print0 | sort -r | while read -r -d '' post; do
1616+ post="${post%/*}"
1717+ echo -n "${post} "
1818+ jq -r '.title' "${post}/meta.json"
1919+ jq -r --arg path "${post#./*/*/}" "${template}" "${post}/meta.json" >> ./index.html
2020+ pandoc -f djot -t html5 \
2121+ --mathml \
2222+ --highlight-style=kate \
2323+ --standalone \
2424+ --metadata-file="${post}/meta.json" \
2525+ "${post}/content.djot" -o "${post}/index.html"
2626+done
2727+2828+sed -n "/${template_end}/,\$p" ./index_template.html >> ./index.html