blog/new-article.sh

31 lines
549 B
Bash
Executable file

#!/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"