mirror of
https://github.com/msfjarvis/msfjarvis.dev.git
synced 2024-06-03 04:18:56 +05:30
21 lines
693 B
Bash
Executable File
21 lines
693 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euxo pipefail
|
|
|
|
function create_post() {
|
|
local title filename postslug postdate
|
|
if [ $# -lt 1 ]; then
|
|
echo -e "\033[01;31mProviding a title is a must!\033[0m"
|
|
return
|
|
else
|
|
title="${*}"
|
|
fi
|
|
postdate="$(date +%Y-%m-%d)"
|
|
postslug="$(echo "${title}" | tr -dc '[:alnum:][:space:]\n\r' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')"
|
|
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!"
|
|
}
|
|
|
|
create_post "${@}"
|