ataricode.com/new

46 lines
910 B
Plaintext
Raw Normal View History

2023-08-30 13:31:57 +00:00
#!/usr/bin/env bash
2023-08-30 13:34:14 +00:00
export ED='vi'
2023-08-30 13:31:57 +00:00
# export ED='vi'
Help()
{
# Display Help
echo "Add a new post to a hugo blog"
echo
echo "Syntax: new -c contentType -t 'some title'"
echo "options:"
2023-08-30 13:37:59 +00:00
echo "-c [required] Content Type: 'blog'"
2023-08-30 13:31:57 +00:00
echo "-t [required] Content Title: \"Any Plain Text At All\""
echo "-h This display."
exit 0
}
while getopts c:t:h flag
do
case "${flag}" in
c) contentType=${OPTARG};;
t) title=${OPTARG};;
h) Help;;
*) echo "-h for help" >&2
exit 1 ;;
esac
done
if [ -z "$contentType" ]; then
echo "Specify a content type. Eg. '-c post'"
exit 1
fi
if [ -z "$title" ]; then
echo "Specify an entry title. Eg. '-t \"The Hamburg Happening\"'"
exit 1
fi
tmp=${title// /-}
filename=${tmp,,}
echo "$filename"
hugo new "${contentType}"/"${filename}".md
$ED content/"${contentType}"/"${filename}".md