jessite/bin/newpost

30 lines
534 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env bash
set -e
cd "$(dirname "$0")/../"
TITLE=$1
SLUG=$(echo $TITLE | iconv -t ascii//TRANSLIT | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z)
PUBLISH_DATE=$(date --rfc-3339=seconds)
FILEPATH="./content/blog/$SLUG.md"
if [ ! -e $FILEPATH ]; then
cat > $FILEPATH <<-EOF
+++
title = "$TITLE"
date = $PUBLISH_DATE
draft = false
[taxonomies]
# these go in quotes, like the title
tags = []
+++
EOF
echo "Created $FILEPATH"
else
echo "ERROR: File already exists $FILEPATH"
fi