nichijou/gen_blogpost.sh
Renken 973cbca918
build(gen): fix markdown toctree
Filename was wrong as well as the format itself.
2023-04-10 14:43:31 +02:00

48 lines
742 B
Bash
Executable file

#!/bin/sh
set -eu
timestamp="$(date '+%s')"
title="$(date '+%Y-%m-%d %H:%M' --date="@$timestamp")"
year="$(date '+%Y')"
month="$(date '+%m')"
archive=./doc/log/archive
for dir in "$archive" "$archive/$year" "$archive/$year/$month"; do
if [ ! -d "$dir" ]; then
mkdir -- "$dir"
name="$(basename -- "$dir")"
if [ "$name" = archive ]; then
name=Archive
fi
<<-EOF cat - >"$dir/index.md"
# $name
\`\`\`{toctree}
---
maxdepth: 1
glob:
---
*/index
\`\`\`
EOF
fi
done
mkdir -- "$archive/$year/$month/$timestamp"
<<-EOF cat - >"$archive/$year/$month/$timestamp/index.md"
# $title
*Written $title*
\`\`\`{contents}
\`\`\`
## TODO
EOF
printf '%s\n' "$archive/$year/$month/$timestamp"
exit 0