summaryrefslogtreecommitdiff
path: root/.tools/render.sh
blob: 273d574769629153a7f647962a7197f0de0ee346 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")/.."

if [[ $# -ne 1 ]]; then
	echo >&2 "Usage: $0 <path/to/post[.html]>"
	echo >&2 "Renders the given post and saves the output to <post.rendered.html>."
	exit 1
fi

postpath="$(echo "$1" | sed 's/\.html$//')"
inpath="${postpath}.html"
outpath="${postpath}.rendered.html"

sed "/<!-- REPLACE CONTENT -->/ { r $inpath"$'\n'"; d; }" <'$template.html' >"$outpath"