Update newpost to take the full title of the article.
This commit is contained in:
parent
9677b3c997
commit
b67a16e652
19
bin/newpost
19
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
|
||||
|
|
Loading…
Reference in a new issue