scripts/generate_post_skeleton: handle empty post slugs
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
b10d1d7374
commit
3f6bf07368
|
@ -12,6 +12,10 @@ function create_post() {
|
|||
fi
|
||||
postdate="$(date +%Y-%m-%d)"
|
||||
postslug="$(echo "${title}" | tr -dc '[:alnum:][:space:]\n\r' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')"
|
||||
[ -z "$postslug" ] && {
|
||||
echo -e "\033[01;31mProviding a title is a must!\033[0m"
|
||||
return
|
||||
}
|
||||
filename="${postslug}.md"
|
||||
printf "+++\ncategories = []\ndate = %s\ndescription = \"\"\ndraft = true\nslug = \"%s\"\ntags = []\ntitle = \"%s\"\n+++\n" "${postdate}" "${postslug}" "${title}" > content/posts/"${filename}"
|
||||
echo "content/posts/${filename} created!"
|
||||
|
|
Loading…
Reference in New Issue