automate blog post generation
Generates a blog post under ./doc/log/archive/$year/$month/$timestamp. It'll come in handy when writing random short thoughts.
This commit is contained in:
parent
71972c3a3d
commit
aa9b8443c9
2 changed files with 52 additions and 0 deletions
|
@ -8,3 +8,9 @@ Unfinished thoughts, unfinished projects.
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
*/index
|
*/index
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:glob:
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
*/*/*/*/index
|
||||||
|
|
46
gen_blogpost.sh
Executable file
46
gen_blogpost.sh
Executable file
|
@ -0,0 +1,46 @@
|
||||||
|
#!/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.rst"
|
||||||
|
$name
|
||||||
|
$(printf '%s\n' "$name" | sed -E 's|.|=|g')
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
$(printf '\t'):glob:
|
||||||
|
$(printf '\t'):maxdepth: 1
|
||||||
|
|
||||||
|
$(printf '\t')*/index
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -- "$archive/$year/$month/$timestamp"
|
||||||
|
|
||||||
|
|
||||||
|
<<-EOF cat - >"$archive/$year/$month/$timestamp/index.rst"
|
||||||
|
$title
|
||||||
|
$(printf '%s\n' "$title" | sed -E 's|.|=|g')
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
|
||||||
|
TODO
|
||||||
|
----
|
||||||
|
EOF
|
||||||
|
|
||||||
|
printf '%s\n' "$archive/$year/$month/$timestamp"
|
||||||
|
exit 0
|
Loading…
Reference in a new issue