Add 'new-article.sh' helper, to quickly spawn new articles

This commit is contained in:
Skia 2024-05-17 21:22:39 +02:00
parent b2b7353110
commit ba6a848b3f

30
new-article.sh Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/bash
BASE_DIR="$(dirname "$0")"
YEAR="$(date '+%Y')"
SLUG="$1"
if [ -z "$SLUG" ]; then
echo ""
echo "Usage: $0 slug"
echo ""
echo " Kickstart a new article with the given 'slug'"
exit 1
fi
ARTICLE_DIR="$BASE_DIR/content/blog/posts/$YEAR/$SLUG"
mkdir -p "$ARTICLE_DIR"
if ! [ -f "$ARTICLE_DIR/index.md" ]; then
cat - >"$ARTICLE_DIR/index.md" <<EOH
+++
title = "$SLUG"
description = ""
date = "$(date '+%Y-%m-%d')"
[taxonomies]
tags = ["list", "of", "tags"]
+++
EOH
fi
exec "$EDITOR" "$ARTICLE_DIR/index.md"