From b67a16e652802f54901e20eb83ae638568df2f12 Mon Sep 17 00:00:00 2001 From: Jessica Phoenix Canady Date: Mon, 8 Jan 2024 16:17:00 -0500 Subject: [PATCH] Update newpost to take the full title of the article. --- bin/newpost | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/bin/newpost b/bin/newpost index 39c16c7..6e9c81f 100755 --- a/bin/newpost +++ b/bin/newpost @@ -4,20 +4,27 @@ set -e cd "$(dirname "$0")/../" -if [ ! -e $1 ]; then - cat > "content/blog/$1.md" <<-EOF +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~ +echo $SLUG +exit +PUBLISH_DATE=$(date --rfc-3339=seconds) +FILEPATH="./content/blog/$SLUG.md" + +if [ ! -e $FILEPATH ]; then + cat > $FILEPATH <<-EOF +++ title = $1 -draft = true +date = $PUBLISH_DATE +draft = false [taxonomies] tags = [] +++ - EOF - echo "Created ./content/blog/$1.md" + echo "Created $FILEPATH" else - echo "ERROR: File already exists ./content/blog/$1.md" + echo "ERROR: File already exists $FILEPATH" fi